- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 180
 
Closed
Labels
Description
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
See below - a partial try has the has_error flag even though a similar if statement does not.
Steps To Reproduce/Bad Parse Tree
Using tree-sitter-python==0.23.6.
(With uv, you can run the code below with 'uv run --with ipython --with tree-sitter-python==0.23.6 --with tree-sitter==0.24.0 ipython')
In [1]: import tree_sitter_python as tspython
   ...: from tree_sitter import Language, Parser, Tree
   ...: 
   ...: py_language = Language(tspython.language())
   ...: py_parser = Parser(py_language)
   ...: print(py_parser.parse(b'if True:').root_node.has_error)
   ...: print(py_parser.parse(b'try:').root_node.has_error)
False
True
See also:
In [2]: print(py_parser.parse(b'if:').root_node)
   ...: print(py_parser.parse(b'try:').root_node)
(module (if_statement condition: (MISSING identifier) consequence: (block)))
(module (ERROR))
Expected Behavior/Parse Tree
I'd expect partial try statements to not be an error.