Skip to content

Multiline infix method call in for-comprehension fails to parse #377

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

Closed
jpaju opened this issue Feb 13, 2024 · 2 comments
Closed

Multiline infix method call in for-comprehension fails to parse #377

jpaju opened this issue Feb 13, 2024 · 2 comments

Comments

@jpaju
Copy link

jpaju commented Feb 13, 2024

Commit of tree-sitter-scala you tested this on

1abd3d9

A code sample showing the error

There are many variants that fail to parse:

for {
  _ <- ZIO.unit *>
         ZIO.unit
} yield ()
for 
  _ <- ZIO.unit *>
         ZIO.unit
yield ()
for _ <- ZIO.unit *>
   ZIO.unit
yield ()

Show the error node

This is the AST of the first example above:

(compilation_unit [0, 0] - [5, 0]
  (ERROR [0, 0] - [5, 0]
    (enumerators [1, 2] - [5, 0]
      (enumerator [1, 2] - [1, 18]
        (wildcard [1, 2] - [1, 3])
        (postfix_expression [1, 7] - [1, 18]
          (field_expression [1, 7] - [1, 15]
            value: (identifier [1, 7] - [1, 10])
            field: (identifier [1, 11] - [1, 15]))
          (operator_identifier [1, 16] - [1, 18])))
      (ERROR [2, 9] - [3, 10]
        (case_class_pattern [2, 9] - [3, 10]
          type: (stable_type_identifier [2, 9] - [2, 17]
            (identifier [2, 9] - [2, 12])
            (type_identifier [2, 13] - [2, 17]))
          (ERROR [3, 0] - [3, 7]))))))

What do you expect the tree to look like

(compilation_unit [0, 2] - [4, 0]
  (for_expression [0, 2] - [2, 12]
    enumerators: (enumerators [1, 4] - [3, 2]
      (enumerator [1, 4] - [1, 29]
        (wildcard [1, 4] - [1, 5])
        (infix_expression [1, 9] - [1, 29]
          left: (field_expression [1, 9] - [1, 17]
            value: (identifier [1, 9] - [1, 12])
            field: (identifier [1, 13] - [1, 17]))
          operator: (operator_identifier [1, 18] - [1, 20])
          right: (field_expression [2, 9] - [2, 16]
            value: (identifier [2, 9] - [2, 12])
            field: (identifier [2, 13] - [2, 17])))))
    body: (unit [3, 9] - [3, 11])))

Where are you experiencing this error?

Both Helix and tree-sitter CLI

@susliko
Copy link
Collaborator

susliko commented Feb 14, 2024

@jpaju Thanks for reporting!
Looks like a duplicate of #358

@jpaju
Copy link
Author

jpaju commented Feb 14, 2024

Ohh, true. I'll close this one 👍🏼

@jpaju jpaju closed this as not planned Won't fix, can't repro, duplicate, stale Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants