Skip to content

bug: Assignment incorrectly parsed as type_alias_statement #321

Description

@zsol

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

This python expression:

type(_).foo = bar

Is incorrectly parsed as a type_alias_statement, but type alias doesn't allow parenthesis on the left hand side of the equals sign.

Steps To Reproduce/Bad Parse Tree

module [0, 0] - [1, 0]
  type_alias_statement [0, 0] - [0, 17]
    type [0, 4] - [0, 11]
      attribute [0, 4] - [0, 11]
        object: parenthesized_expression [0, 4] - [0, 7]
          identifier [0, 5] - [0, 6]
        attribute: identifier [0, 8] - [0, 11]
    type [0, 14] - [0, 17]
      identifier [0, 14] - [0, 17]

Expected Behavior/Parse Tree

module [0, 0] - [1, 0]
  expression_statement [0, 0] - [0, 17]
    assignment [0, 0] - [0, 17]
      left: attribute [0, 0] - [0, 11]
        object: call [0, 0] - [0, 7]
          function: identifier [0, 0] - [0, 4]
          arguments: argument_list [0, 4] - [0, 7]
            identifier [0, 5] - [0, 6]
        attribute: identifier [0, 8] - [0, 11]
      right: identifier [0, 14] - [0, 17]

Repro

type(_).foo = bar

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