Skip to content

bug: Multiple union types are not well supported #334

Description

@jecisc

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)

Compiled from main

Describe the bug

I am trying to parse some code with union types with more than 2 possible types and TreeSitter python does not seems to manage this right.

Steps To Reproduce/Bad Parse Tree

Here is the minimal example I can produce:

def f( arg: IO[bytes] | int | float ): pass

Here is what I get:

Image

We see a union_type node with two types. I was expecting 3.

This is even worst with this piece of code:

def f( arg: IO[bytes] | int | List[int] ): pass
Image

We end up with a subscript for List[int] instead of a generic type

Expected Behavior/Parse Tree

Instead of the binary_operator node containing identifiers I was expecting the union_type to contain 2..n children. Currently union_type seems to be possible only with 2 children.

Repro

I used Pharo-Tree-Sitter integration to produce the tree from this piece of code:



def f( arg: IO[bytes] | int | List[int] ): pass

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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