tree-sitter / tree-sitter-scala

Scala grammar for tree-sitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pattern declaration/definition of val/var #2

susliko opened this issue · comments

Commit of tree-sitter-scala you tested this on

374709c

A code sample showing the error

The fix #254 doesn't work for more than two identifiers:

object A:
  val res1, res2, res3 = x

Replacing -1 precedence with conflict resolution would probably fix this

Show the error node

(compilation_unit [0, 0] - [3, 0]
  (object_definition [0, 0] - [3, 0]
    name: (identifier [0, 7] - [0, 8])
    body: (template_body [0, 8] - [3, 0]
      (val_definition [1, 2] - [1, 26]
        pattern: (identifier [1, 6] - [1, 10])
        (ERROR [1, 10] - [1, 22]
          name: (identifier [1, 12] - [1, 16])
          name: (identifier [1, 18] - [1, 22]))
        value: (identifier [1, 25] - [1, 26])))))

What do you expect the tree to look like

(compilation_unit [0, 0] - [3, 0]
  (object_definition [0, 0] - [3, 0]
    name: (identifier [0, 7] - [0, 8])
    body: (template_body [0, 8] - [3, 0]
      (val_definition [1, 2] - [1, 26]
        pattern: (identifiers [1, 6] - [1, 22]
          (identifier [1, 6] - [1, 10])
          (identifier [1, 12] - [1, 16])
          (identifier [1, 18] - [1, 22]))
        value: (identifier [1, 25] - [1, 26])))))

Where are you experiencing this error?

No response

Same problem with var:

object A:
  var a,b = false
(compilation_unit [0, 0] - [2, 0]
  (object_definition [0, 0] - [2, 0]
    name: (identifier [0, 7] - [0, 8])
    body: (template_body [0, 8] - [2, 0]
      (var_definition [1, 2] - [1, 17]
        pattern: (identifier [1, 6] - [1, 7])
        (ERROR [1, 7] - [1, 9]
          name: (identifier [1, 8] - [1, 9]))
        value: (boolean_literal [1, 12] - [1, 17])))))