-
-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move fix Issue 12153 to frontend #4062
Conversation
|
Responding to comments in the other PR (From what I gather, Kenji did initially fix it in the frontend?)
With gdc and this PR, the behaviour in the above test doesn't change. |
|
Likewise this code samples does not change behaviour:
Nor this:
|
|
IIUC this implementing what I suggested in this comment but has no effect on my other concerns from that PR. I'll have to take another look because I can't remember how |
Correct. Here, the transformation is done on the lhs of an AssignExp only. |
|
Have you had any time to mull over this? |
|
Nope. |
|
Shouldn't the condition be |
|
This change will introduce a regression with following case: int[1] i, j;
bool b = true;
int n = 0;
(b ? i : j)[0..1][n..$] = [4];
assert(i == [4]);So the better code would be: // For conditional operator, both branches need conversion.
SliceExp *se = (SliceExp *)e1;
while (se->e1->op == TOKslice)
se = (SliceExp *)se->e1;
if (se->e1->type->toBasetype()->ty == Tsarray)
{
se->e1 = se->e1->modifiableLvalue(sc, e1);
if (se->e1->op == TOKerror)
return se->e1;
}Additionally, I'd keep the code in |
Fixed and added regression test.
That's fine, you understand it better than me. |
Not that I can think off the top of my head. |
|
Shouldn't have blindly copied and pasted your proposed fix @9rnsr :) |
What you have to watch out for are operations that do not have any side-effects, but may still create a temporary. Conditional operators fall under this category. |
|
Auto-merge toggled on |
Move fix Issue 12153 to frontend
See #3285
Moves the fix into the front-end so everyone benefits.
NB: I haven't yet read any of the comments in that PR.