RFR: 8312619: Strange error message when switching over long

Vicente Romero vromero at openjdk.org
Tue Jul 25 16:21:41 UTC 2023


On Tue, 25 Jul 2023 14:36:31 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> For code like:
> 
> public class SelectorTypeNotAllowed {
>     private void noLong(long sel) {
>         switch (sel) {
>             case 0L -> {}
>             default -> {}
>         }
>     }
> }
> 
> 
> which is invalid (due to the `long` selector) produces this compile-time error:
> 
> /tmp/SelectorTypeNotAllowed.java:4: error: constant label of type long is not compatible with switch selector type long
>             case 0L -> {}
>                  ^
> 1 error
> 
> 
> This is a confusing error message. The proposal here is to change the error message to:
> 
> /tmp/SelectorTypeNotAllowed.java:3: error: selector type long is not allowed
>         switch (sel) {
>                ^
> 1 error

looks good

-------------

Marked as reviewed by vromero (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/15020#pullrequestreview-1545890747


More information about the compiler-dev mailing list