elm-tooling / tree-sitter-elm

Tree sitter implementation for elm
https://elm-tooling.github.io/tree-sitter-elm/
MIT License
75 stars 14 forks source link

Anonymous function expr not parsed correctly #43

Closed jmbockhorst closed 4 years ago

jmbockhorst commented 4 years ago

A anonymous function like:

func =
  (\_ -> get h w)

Gets parsed as:

(file [0, 0] - [2, 0]
  (value_declaration [0, 0] - [1, 17]
    (function_declaration_left [0, 0] - [0, 4]
      (lower_case_identifier [0, 0] - [0, 4]))
    (eq [0, 5] - [0, 6])
    (parenthesized_expr [1, 2] - [1, 17]
      (left_parenthesis [1, 2] - [1, 3])
      (function_call_expr [1, 3] - [1, 16]
        (anonymous_function_expr [1, 3] - [1, 14]
          (backslash [1, 3] - [1, 4])
          (pattern [1, 4] - [1, 5]
            (anything_pattern [1, 4] - [1, 5]
              (underscore [1, 4] - [1, 5])))
          (arrow [1, 6] - [1, 8])
          (function_call_expr [1, 9] - [1, 14]
            (value_expr [1, 9] - [1, 12]
              (value_qid [1, 9] - [1, 12]
                (lower_case_identifier [1, 9] - [1, 12])))
            (value_expr [1, 13] - [1, 14]
              (value_qid [1, 13] - [1, 14]
                (lower_case_identifier [1, 13] - [1, 14])))))
        (value_expr [1, 15] - [1, 16]
          (value_qid [1, 15] - [1, 16]
            (lower_case_identifier [1, 15] - [1, 16]))))
      (right_parenthesis [1, 16] - [1, 17]))))

Inside the parenthesis gets incorrectly parsed as an unneeded function_call_expr with \_ -> get h as the target and w as the param.