Integrated: 8312619: Strange error message when switching over long

Jan Lahoda jlahoda at openjdk.org
Wed Jul 26 10:39:00 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

This pull request has now been integrated.

Changeset: cc2a75e1
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/cc2a75e11c4b5728c547aa764067427fdea8c941
Stats:     50 lines in 4 files changed: 43 ins; 0 del; 7 mod

8312619: Strange error message when switching over long

Reviewed-by: vromero

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

PR: https://git.openjdk.org/jdk/pull/15020


More information about the compiler-dev mailing list