slackhq / tree-sitter-hack

Hack grammar for tree-sitter
MIT License
33 stars 15 forks source link

[BUG] Enum classes not parsed #43

Closed 4e554c4c closed 2 years ago

4e554c4c commented 2 years ago

Describe the bug

Enum classes do not appear to be parsable

Requirements (place an x in each of the [ ])**

To Reproduce

Using the example from https://docs.hhvm.com/hack/built-in-types/enum-class

enum class Random : mixed {
  int X = 42;
  string S = 'foo';
}

fails to parse. Parse tree:

enum_declaration [0, 0] - [3, 1]
  ERROR [0, 5] - [0, 10]
    identifier [0, 5] - [0, 10]
  name: identifier [0, 11] - [0, 17]
  type: type_specifier [0, 20] - [0, 25]
  enumerator [1, 2] - [1, 13]
    identifier [1, 2] - [1, 5]
    ERROR [1, 6] - [1, 7]
      identifier [1, 6] - [1, 7]
    integer [1, 10] - [1, 12]
  enumerator [2, 2] - [2, 19]
    identifier [2, 2] - [2, 8]
    ERROR [2, 9] - [2, 10]
      identifier [2, 9] - [2, 10]
    string [2, 13] - [2, 18]

Expected behavior

Enum classes are correctly parsed

OS version(s): Linux