Skip to content

bug: Line continuations for aliases from LuaCATS Annotations is not parsing #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks done
ColinKennedy opened this issue Sep 21, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@ColinKennedy
Copy link

Did you check existing issues?

  • I have read all the tree-sitter docs if it relates to using the parser
  • I have searched the existing issues

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

tree-sitter 0.22.5

Describe the bug

Possibly related to - #12

There's an example of line continuations in the LuaCATS Annotations page that this parser doesn't currently handle. It's under @alias's examples, here: https://luals.github.io/wiki/annotations/#alias

---@alias DeviceSide
---| '"left"' # The left side of the device
---| '"right"' # The right side of the device
---| '"top"' # The top side of the device
---| '"bottom"' # The bottom side of the device
---| '"front"' # The front side of the device
---| '"back"' # The back side of the device

This same tree parses as expected with llscheck, which further leads me to believe it's a bug.

Steps To Reproduce/Bad Parse Tree

Make a file with

@alias DeviceSide
| '"left"' # The left side of the device
| '"right"' # The right side of the device
| '"top"' # The top side of the device
| '"bottom"' # The bottom side of the device
| '"front"' # The front side of the device
| '"back"' # The back side of the device

Then run tree-sitter parse that_file.lua

Errors with

(documentation [0, 0] - [8, 0]
  (alias_annotation [0, 0] - [6, 40]
    (identifier [0, 7] - [0, 17])
    (ERROR [1, 0] - [6, 1]
      (literal_type [1, 2] - [1, 10])
      (comment [1, 10] - [1, 40])
      (literal_type [2, 2] - [2, 11])
      (comment [2, 11] - [2, 42])
      (literal_type [3, 2] - [3, 9])
      (comment [3, 9] - [3, 38])
      (literal_type [4, 2] - [4, 12])
      (comment [4, 12] - [4, 44])
      (literal_type [5, 2] - [5, 11])
      (comment [5, 11] - [5, 42]))
    (literal_type [6, 2] - [6, 10])
    (comment [6, 10] - [6, 40])))

Expected Behavior/Parse Tree

(documentation [0, 0] - [2, 0]
  (alias_annotation [0, 0] - [0, 84]
    (identifier [0, 7] - [0, 17])
    (union_type [0, 18] - [0, 84]
      (literal_type [0, 18] - [0, 26])
      (union_type [0, 29] - [0, 84]
        (literal_type [0, 29] - [0, 38])
        (union_type [0, 41] - [0, 84]
          (literal_type [0, 41] - [0, 48])
          (union_type [0, 51] - [0, 84]
            (literal_type [0, 51] - [0, 61])
            (union_type [0, 64] - [0, 84]
              (literal_type [0, 64] - [0, 73])
              (literal_type [0, 76] - [0, 84]))))))))

or something similar

Repro

tree-sitter parse that_file.lua

@ColinKennedy ColinKennedy added the bug Something isn't working label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant