slackhq / tree-sitter-hack

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

[BUG] include and require confuse the parser when used as function calls on pipe vars #64

Closed andryak closed 6 months ago

andryak commented 1 year ago

Describe the bug

The parser does not treat include, include_once, require and require_once as keywords, and thus gets confused when these are used as the name of a function called on a pipe expression.

For instance, the following code:

new Foo() |> $$->include();
new Foo() |> $$->include_once();
new Foo() |> $$->require();
new Foo() |> $$->require_once();

Is incorrectly parsed as follows:

(ERROR
      (new_expression
        (qualified_identifier
          (identifier))
        (arguments))
      (pipe_variable)
      (ERROR
        (parameters))
      (new_expression
        (qualified_identifier
          (identifier))
        (arguments))
      (pipe_variable)
      (ERROR
        (parameters))
      (new_expression
        (qualified_identifier
          (identifier))
        (arguments))
      (pipe_variable)
      (ERROR
        (parameters))
      (new_expression
        (qualified_identifier
          (identifier))
        (arguments))
      (pipe_variable)
      (parameters))

Requirements

To Reproduce

Add new test with content new Foo() |> $$->include();, then run tree-sitter test

Expected behavior

No errors are reported in the syntax tree.