Skip to content
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

[Enhanced Switch] Bogus duplicate case error from ECJ #3334

Closed
srikanth-sankaran opened this issue Nov 22, 2024 · 1 comment · Fixed by #3310
Closed

[Enhanced Switch] Bogus duplicate case error from ECJ #3334

srikanth-sankaran opened this issue Nov 22, 2024 · 1 comment · Fixed by #3310
Assignees
Labels
bug Something isn't working compiler Eclipse Java Compiler (ecj) related issues regression Something was broken by a previous change

Comments

@srikanth-sankaran
Copy link
Contributor

Found by code inspection & white box testing:

The program below when compiled with javac and run produces the output:

E1.ONE
E1.TWO
E2.ONE
E2.TWO
E1.TWO
E2.ONE
E2.TWO
E2.ONE
E2.TWO
E2.TWO

but is rejected by ECJ with three errors of: Duplicate case

public sealed interface X {
	public static void main(String[] args) {
        bar(E1.ONE);
        bar(E1.TWO);
        bar(E2.ONE);
        bar(E2.TWO);
	}
	public static void bar(X x) {
		switch (x) {
		case E1.ONE: 
			System.out.println("E1.ONE");
		case E1.TWO: 
			System.out.println("E1.TWO");
		case E2.ONE:
			System.out.println("E2.ONE");
		case E2.TWO:
			System.out.println("E2.TWO");
		}
	}
}
enum E1 implements X { ONE, TWO}
enum E2 implements X { ONE, TWO}
@srikanth-sankaran srikanth-sankaran self-assigned this Nov 22, 2024
@srikanth-sankaran srikanth-sankaran added bug Something isn't working regression Something was broken by a previous change compiler Eclipse Java Compiler (ecj) related issues labels Nov 22, 2024
@srikanth-sankaran
Copy link
Contributor Author

This regression appears to brought on by the commit 37b9382 made for #2866

However at 4.33 we reject the program with a different bogus error about enhanced switch requiring a default. The switch is exhaustive and doesn't require a default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler Eclipse Java Compiler (ecj) related issues regression Something was broken by a previous change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant