-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
fix Issue 17722 - Wrong diagnostic using __traits(compiles, e1 && e2) expressions #7067
Conversation
src/ddmd/expressionsem.d
Outdated
if (f1 || f2) | ||
{ | ||
result = new ErrorExp(); | ||
return; | ||
} | ||
|
||
if (exp.e2.type.ty == Tvoid) | ||
if (e2x.type.ty == Tvoid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By assigning to exp.type
here, the type gets disconnected from the operands, putting exp
into an invalid state. A better approach is to assign to a t
here, and assign exp.type = t;
when the operands are assigned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, you mean that if the first time round the caller ignores the propagated error and runs semantic on this expression again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is to say, setting type means that you are saying this expression has completed its semantic, when infact it could instead return error (in which case, semantic did not complete).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right. Even if it doesn't, it looks suspicious, which will cause extra work for anyone trying to understand the code.
src/ddmd/expressionsem.d
Outdated
exp.type = Type.tvoid; | ||
else | ||
{ | ||
exp.e2 = exp.e2.toBoolean(sc); | ||
e2x = e2x.toBoolean(sc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
src/ddmd/expressionsem.d
Outdated
return; | ||
} | ||
|
||
exp.e1 = e1x; | ||
exp.e2 = e2x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put exp.type = t;
here.
src/ddmd/expressionsem.d
Outdated
if (f1 || f2) | ||
{ | ||
result = new ErrorExp(); | ||
return; | ||
} | ||
|
||
if (exp.e2.type.ty == Tvoid) | ||
if (e2x.type.ty == Tvoid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same problem as above.
Actually in this case, as the logic in-between setting |
When fixing a bugzilla issue, please put the PR URL in the bugzilla issue, so somebody else doesn't waste time trying to fix it because he's ignorant there is an extant fix already. |
I still think that the cross reference should be handled by the dlang bot/whatever github hook posts messages to bugzilla on commits. |
Fixed the wrong filename in the test output. |
Tests pass. |
@@ -0,0 +1,13 @@ | |||
/* TEST_OUTPUT: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please merge these two test files into one. It'll consume half the resources of the autotester that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's kept as two separate because the compiler doesn't issue an error for both when together in the same file.
You'd have had half the work to do if you'd pulled #7069 :-) |
I'd still end up doing double work, because then I'd have to rebase this PR. |
Manipulates
e1
ande2
in a locale1x
ande2x
var respectively, and assigns them back if semantic was successful.This is the same as what other binary expressions do via
binSemantic
/binSemanticProp
.