[jdk17] RFR: 8268859: jshell throws exception while parsing illegal "case true"

Maurizio Cimadamore mcimadamore at openjdk.java.net
Tue Jul 6 10:35:48 UTC 2021


On Fri, 2 Jul 2021 12:11:52 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> Currently, broken case labels like `case true t` parse as patterns, whose type is `true`, which then fails later during annotation handling. This patch is trying to improve (and fix) the pattern/expression disambiguation again, making it more explicit than before. With this patch, only labels that begin with `<type> <name>` should be considered patterns.
> 
> The recently added no-preview part of `SwitchErrors` is moved to `PatternErrorRecovery.java`, because that indeed turned out to be difficult to maintain.

Parser changes look good - splitting lambda analysis from pattern analysis and finding commonalities (e.g. skipping annotations) seems like a wise move.

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

Marked as reviewed by mcimadamore (Reviewer).

PR: https://git.openjdk.java.net/jdk17/pull/202


More information about the compiler-dev mailing list