An errata about the production rule w.r.t. "CaseConstant" in JLS 14.11.1 Switch Blocks (Java SE 14 & 15)
Alex Buckley
alex.buckley at oracle.com
Mon Dec 20 20:01:58 UTC 2021
It's not uncommon for the grammar to accept a relatively wide range of
inputs which are then constrained by semantic rules ("... a compile-time
error occurs"). Using ConditionalExpression also avoids introducing a
little-used EnumConstantName production.
Alex
On 10/21/2020 3:04 PM, Brian Jeong wrote:
> The production rule w.r.t. the non-terminal symbol "CaseConstant" in JLS
> 14.11.1 Switch Blocks (Java SE 14
> <https://docs.oracle.com/javase/specs/jls/se14/html/jls-14.html#jls-14.11.1>
> & 15
> <https://docs.oracle.com/javase/specs/jls/se15/html/jls-14.html#jls-14.11.1>)
> is given as:
>
>
> *CaseConstant:ConditionalExpression*
>
> However, this doesn't seem to meet the sentence:
>
> *Every case constant must be either a constant expression (§15.29) or the
> name of an enum constant (§8.9.1), or a compile-time error occurs*.
>
> It looks like a minor erratum, which can be corrected as:
>
> *CaseConstant:ConstantExpression EnumConstantName EnumConstantName:Identifier*
>
> Please review this.
> Thanks,
>
> - Brian
More information about the jls-jvms-spec-comments
mailing list