Skip to content

Parsing error for annotations on catch parameters #208

Description

@theawless

Sample:

try {
} catch (T1 | @A3 T2 e) {
}
program [0, 0] - [3, 0]
  try_statement [0, 0] - [2, 1]
    try [0, 0] - [0, 3]
    body: block [0, 4] - [1, 1]
      { [0, 4] - [0, 5]
      } [1, 0] - [1, 1]
    catch_clause [1, 2] - [2, 1]
      catch [1, 2] - [1, 7]
      ( [1, 8] - [1, 9]
      catch_formal_parameter [1, 9] - [1, 20]
        catch_type [1, 9] - [1, 17]
          type_identifier [1, 9] - [1, 11]
          | [1, 12] - [1, 13]
          ERROR [1, 14] - [1, 15]
            @ [1, 14] - [1, 15]
          type_identifier [1, 15] - [1, 17]
        name: identifier [1, 18] - [1, 20]
      ERROR [1, 21] - [1, 22]
        identifier [1, 21] - [1, 22]
      ) [1, 22] - [1, 23]
      body: block [1, 24] - [2, 1]
        { [1, 24] - [1, 25]
        } [2, 0] - [2, 1]

I noticed that if I add an annotation on T1, that works fine probably because it's considered a modifier.

But it breaks when I add an annotation on T2, which is valid syntax according to JLS: https://docs.oracle.com/javase/specs/jls/se24/html/jls-14.html#jls-CatchType

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions