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

[21][Enhanced Switch] Bogus error: "Cannot mix pattern with other case labels" #3169

Closed
srikanth-sankaran opened this issue Oct 27, 2024 · 0 comments · Fixed by #3310
Closed
Assignees
Milestone

Comments

@srikanth-sankaran
Copy link
Contributor

Test case: (project should be built at source level 21) (22+ works ok)

public class X {	
	static void foo(Object o) {
	    switch (o) {
	        case Character c, Integer i:                 // Compile-time error
	            break;
	        default:
	        	break;
	    }
	}
} 

We report 3 errors on line 4:

	- Named pattern variables are not allowed here
	- Named pattern variables are not allowed here
	- Cannot mix pattern with other case labels

The last one i.e Cannot mix pattern with other case labels is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant