Skip to content
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

bug: Special case not managed by the parser, when an expression is split without a backslash and the second line is dedented. #256

Open
2 tasks done
martinett opened this issue Feb 26, 2024 · 0 comments
Labels

Comments

@martinett
Copy link

martinett commented Feb 26, 2024

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 of tree-sitter-python

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

No response

Describe the bug

If an expression is split into 2 lines without a backslash and not after a comma, and the second line is de-indented making it go outside of the instruction block (outside of an if, for example), the parser thinks there is an error, while python correctly interprets it.
Example of minimal code :

if True:
  print(1+
1)

But it also works with a multiplication star or any operator before the split.
It also works with a subscript statement, or any parenthesized which can be split as we want, according to Python.
And it also works inside a loop or any statement with an indented block.

It may works with other syntactic exceptions, but I can't find a more general pattern.

Steps To Reproduce/Bad Parse Tree

This produce the following error :

(module
  (if_statement condition: (true)
    (ERROR (integer))
    consequence: (block))
  (ERROR (integer)))

Expected Behavior/Parse Tree

(module
  (if_statement condition: (true)
    consequence: (block
      (expression_statement
        (call function: (identifier)
        arguments:
          (argument_list
            (binary_operator left: (integer) right: (integer))))))))

Repro

if True:
  print(1+
1)
@martinett martinett added the bug label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant