-
Notifications
You must be signed in to change notification settings - Fork 142
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
[JEP 488][Preview][Primitive Patterns] ECJ crashes compiling switch over void typed selector expression #3722
[JEP 488][Preview][Primitive Patterns] ECJ crashes compiling switch over void typed selector expression #3722
Conversation
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.
No major issues. Three minor potential follow up comments.
" switch (foo()) {\n" + | ||
" ^^^^^\n" + | ||
"Expression must return a value\n" + | ||
"----------\n"); |
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.
- Are both arms of the ternary identical now ? They appear so. Could they be collapsed together ?
- With the message
Expression must return a value
I feel the quality of the diagnostic actually degrades in this context. How about we change the message toExpression has no value
- ("to switch on", "to synchronize with" etc left to be understood) ?
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.
ad (1): your eagle eyes spotted correctly :)
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.
ad (2): I agree, that message is a bit odd.
"has no value" makes me think of "worthless" :)
Perhaps we can agree on "yields no value"?
Let me see if that change will cause a landslide in our tests.
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.
Let me see if that change will cause a landslide in our tests.
Quite to the contrary. I can't find any tests covering the 2 pre-existing uses of this error message. I'll add a couple.
if (expressionType.id == TypeIds.T_void) { | ||
upperScope.problemReporter().illegalVoidExpression(this.expression); | ||
break checkType; | ||
} |
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.
Admittedly, this is even more corner case: What about 'V'oid methods ? should they be handled here too ? (Actually what can a Void method return other than null ? I have poor understanding here)
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.
Indeed I can't see how switching over Void
could ever do anything useful (you'd get NPE at best). Yet doing so would be legal code, in contrast to void
.
void typed selector expression + report error rather than crashing Fixes eclipse-jdt#3369
void typed selector expression + advoid secondary error + tentatively adjust tests from eclipse-jdt#2385 Fixes eclipse-jdt#3369
void typed selector expression + rephrase error message + add tests for pre-existing cases of that error Fixes eclipse-jdt#3369
c87d1e2
to
01543cb
Compare
Fixes #3369