-
-
Notifications
You must be signed in to change notification settings - Fork 181
Open
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
When using the | union operator, the output structure depends on the order of the types. For example:
def example(
a: str | list[float] | bool,
b: list[float] | str | bool,
):
pass- The types of
aare parsed to recursivebinary_operators, each with "right" and "left" nodes andlist[float]is parsed tovalueand subscript - types of
bare parsed touniontype, wherelist[float]is parsed asgeneric_typeandstr | booltobinary_operator.
Steps To Reproduce/Bad Parse Tree
Use the example above in the tree-sitter playground for python - https://tree-sitter.github.io/tree-sitter/7-playground.html
Expected Behavior/Parse Tree
I'd expect to get a consistent parsing, for example a recursive binary_operator or union.
Regarding the the subscript versus generic_type I believe it's similar to previous issue - #291 so I guess it's not solvable.
Repro
def example(
a: str | list[float] | bool,
b: list[float] | str | bool,
):
pass