Open
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
a
are parsed to recursivebinary_operator
s, each with "right" and "left" nodes andlist[float]
is parsed tovalue
and subscript - types of
b
are parsed tounion
type, wherelist[float]
is parsed asgeneric_type
andstr | bool
tobinary_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