-
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 #3369
Comments
From a cursory reading of JEP488 and Draft JLS changes I haven't been able to ascertain the right behavior here: 14.11 has been modified to say |
Not sure this should compile, but does with both javac and ECJ:
Not sure this should not (two nots there) compile, but doesn't with both ECJ and javac: Both complain about missing default
|
nice try :)
I guess we should complain something like "value needed", i.e., |
i got a EmptyStackException in |
In that console log, I don't see a stack trace, just one instance of the text EmptySta - With that it is not possible to conclude much. Any pop()/peek() on any stack is a candidate. I see 68 calls to java.util.Stack.pop() in my workspace (only two in batch compiler) Are you able to get any more information ?? |
You are not going to find any code that switches over void type in JDT any case :) |
Don't know how to get the stacktrace. i could reproduce it with https://github.com/eclipse-jdt/eclipse.jdt.core/pull/3578/files :
|
could generate the stack, but seems unrelated:
|
The first part of this is captured in "5.7 Testing Contexts" by:
For the next part "14.1.1 Switch Blocks" says:
In "4.1. The Kinds of Types and Values" the null type is introduced with no sign of it being a reference type. Hence I agree that the example lacks backing by JLS.
I share your doubts. Both points asked here: https://mail.openjdk.org/pipermail/compiler-dev/2025-January/029306.html => Answer is here: https://bugs.openjdk.org/browse/JDK-8348901 |
After that excursion about the null type, let's not forget that this issue is about |
void typed selector expression + report error rather than crashing Fixes eclipse-jdt#3369
@srikanth-sankaran test failures pointed me to #2385 where you added tests expecting an error like
I admit I'm Next I see that compilers consistently comment this ... void foo() { }
Object o = foo(); ... saying So I searched a bit more whether or not JLS considers
So clearly JLS isn't clear whether void is a type or not. Therefor we seem to be free to choose our error messages following one interpretation or another. The error I opted for is from void foo() {}
...
synchronized(foo()) { } => But even existing ecj is miserably inconsistent: public class VoiDTest {
void bar() {
synchronized(bar()) {
Object o = bar();
assert bar() : bar();
}
}
} gives:
javac is similarly (but differently) creative:
Do you see the error at line 3? 👀 => Do you see some system behind this madness, which we should try to adhere to, or is it up to personal taste of the one who introduces a new error detection? |
void typed selector expression + advoid secondary error + tentatively adjust tests from eclipse-jdt#2385 Fixes eclipse-jdt#3369
@srikanth-sankaran do you need more time to reply / review? |
I will complete the review before end of business day today ... |
I am OK with different verbiage in different circumstances - we don't have to bend over backwards to unify into a consistent single diagnostic - as long as each is clear. I have left a comment elsewhere suggesting we say "Expression has no value" rather than "Expression must return a value" - A void method cannot return a value, so "has no value" is better I feel |
Strange indeed. This usually is indicative of a parse error - although I don't see why it should happen in this context |
void typed selector expression + rephrase error message + add tests for pre-existing cases of that error Fixes eclipse-jdt#3369
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
Fixed by #3722. |
Found by code inspection and white box testing:
ECJ crashes compiling the following code; javac complains
error: the switch statement does not cover all possible input values
Stack trace on master (problem can be seen from 4.34 M2)
The text was updated successfully, but these errors were encountered: