Skip to content

bug: generates ERROR nodes for valid Python code tree-sitter-python #313

@Acture

Description

@Acture

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

When parsing valid Python code with , ERROR nodes are unexpectedly generated. Specifically, in the provided example, the statement causes the parser to generate an ERROR node, even though the syntax is fully valid Python. tree-sitter-python``print

  • : 0.23.6 tree-sitter-python
  • Language binding: Rust (via crate) tree-sitter
  • OS: macOS

Steps To Reproduce/Bad Parse Tree

  1. Use the following Python code snippet as input: def test(): print("hello")
  2. Use rust binding to parse it.

Node: source_file
Node text: def test():
print("hello")
Node: ERROR
Node text: def test():
print("hello")
Node: call_expression
Node text: print("hello")
Node: arguments
Node text: ("hello")
Node: )
Node text: )
Node: string_literal
Node text: "hello"
Node: "
Node text: "
Node: string_content
Node text: hello
Node: "
Node text: "
Node: (
Node text: (
Node: identifier
Node text: print
Node: ERROR
Node text: ):
Node: :
Node text: :
Node: )
Node text: )
Node: (
Node text: (
Node: identifier
Node text: test
Node: identifier
Node text: def

Expected Behavior/Parse Tree

Expected to parse the function successfully.

Repro

# Example code that causes the issue
def test():
  # Code that fails to parse, or causes an error
  print("hello")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions