RFR: 8308642: Unhelpful pattern switch error: illegal fall-through to a pattern

Maurizio Cimadamore mcimadamore at openjdk.org
Mon May 27 09:30:02 UTC 2024


On Thu, 23 May 2024 10:27:46 GMT, Aggelos Biboudis <abimpoudis at openjdk.org> wrote:

> Improves two error messages regarding fall-through. Two examples source files after this patch is applied:
> 
> 
>> javac jdk/test/langtools/tools/javac/diags/examples/FlowsThroughFromPattern.java                                                                                                       1m 35s
> jdk/test/langtools/tools/javac/diags/examples/FlowsThroughFromPattern.java:29: error: illegal fall-through from a pattern
>             case String str:
>                  ^
>   the current case label is missing a break
> 1 error
> 
>> javac jdk/test/langtools/tools/javac/diags/examples/FlowsThroughToPattern.java  
> jdk/test/langtools/tools/javac/diags/examples/FlowsThroughToPattern.java:30: error: illegal fall-through to a pattern
>             case Object obj: break;
>                  ^
>   the previous case label is missing a break
> 1 error

Nitpick: we do have some other error messages where the second line provides more details. If you search in `compiler.properties` you will find that, often, that second line is wrapped in parenthesis. I suggest the same should be done here.

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

PR Review: https://git.openjdk.org/jdk/pull/19361#pullrequestreview-2080473323


More information about the compiler-dev mailing list