Skip to content

Grammar ambiguities causing crashes when using assert and module as identifiers #4928

@johannescoetzee

Description

@johannescoetzee

There are two different bugs here, but I decided to include them in one issue/PR since the fix for both is quite simple and they are related.

Problem 1

In Java < 1.4, assert is not yet a keyword and can therefore be used as a regular identifier. There is an ambiguity in the grammar that causes a parse error when attempting to parse the statement:

assert++;

The parser currently tries to parse this as an assert statement followed by a PREFIX_INCREMENT UnaryExpr. Parsing the UnaryExpr then fails since there is no expression following the ++.

Problem 2

module is a conditional keyword that can still be used as a package name. #4910 introduced a new grammar ambiguity causing a parse error when attempting to parse an import statement for a package starting with module:

import module.Foo

The parser attempts to parse this as a module import import module .Foo and crashes when attempting to parse the name since a name cannot start with ..

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions