Open mingodad opened 9 months ago
tree-sitter --version
tree-sitter 0.20.9 (4f3a3debe86ec8261f48d950ce5b65ba92d26496)
The sample code shown bellow is parsed fine on the online playground bu fails with this repo:
def get_var(name) -> T[bool] or None: return 0
Playground:
[module](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [2, 0] [function_definition](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [1, 12] name: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 4] - [0, 11] parameters: [parameters](https://tree-sitter.github.io/tree-sitter/playground#) [0, 11] - [0, 17] [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 12] - [0, 16] return_type: [type](https://tree-sitter.github.io/tree-sitter/playground#) [0, 21] - [0, 36] [boolean_operator](https://tree-sitter.github.io/tree-sitter/playground#) [0, 21] - [0, 36] left: [subscript](https://tree-sitter.github.io/tree-sitter/playground#) [0, 21] - [0, 28] value: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 21] - [0, 22] subscript: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 23] - [0, 27] right: [none](https://tree-sitter.github.io/tree-sitter/playground#) [0, 32] - [0, 36] body: [block](https://tree-sitter.github.io/tree-sitter/playground#) [1, 4] - [1, 12] [return_statement](https://tree-sitter.github.io/tree-sitter/playground#) [1, 4] - [1, 12] [integer](https://tree-sitter.github.io/tree-sitter/playground#) [1, 11] - [1, 12]
This repo:
(module [0, 0] - [2, 0] (function_definition [0, 0] - [1, 12] name: (identifier [0, 4] - [0, 11]) parameters: (parameters [0, 11] - [0, 17] (identifier [0, 12] - [0, 16])) return_type: (type [0, 21] - [0, 28] (generic_type [0, 21] - [0, 28] (identifier [0, 21] - [0, 22]) (type_parameter [0, 22] - [0, 28] (type [0, 23] - [0, 27] (identifier [0, 23] - [0, 27]))))) (ERROR [0, 29] - [0, 36] (identifier [0, 29] - [0, 31]) (none [0, 32] - [0, 36])) body: (block [1, 4] - [1, 12] (return_statement [1, 4] - [1, 12] (integer [1, 11] - [1, 12]))))) pyparser-nb/test.py 0.10 ms 535 bytes/ms (ERROR [0, 29] - [0, 36])
tree-sitter parse test.py
module [0, 0] - [2, 0] function_definition [0, 0] - [1, 12] name: identifier [0, 4] - [0, 11] parameters: parameters [0, 11] - [0, 17] identifier [0, 12] - [0, 16] return_type: type [0, 21] - [0, 36] boolean_operator [0, 21] - [0, 36] left: subscript [0, 21] - [0, 28] value: identifier [0, 21] - [0, 22] subscript: identifier [0, 23] - [0, 27] right: none [0, 32] - [0, 36] body: block [1, 4] - [1, 12] return_statement [1, 4] - [1, 12] integer [1, 11] - [1, 12]
Did you check existing issues?
Tree-Sitter CLI Version, if relevant (output of
tree-sitter --version
)tree-sitter 0.20.9 (4f3a3debe86ec8261f48d950ce5b65ba92d26496)
Describe the bug
The sample code shown bellow is parsed fine on the online playground bu fails with this repo:
Playground:
This repo:
Steps To Reproduce/Bad Parse Tree
tree-sitter parse test.py
Expected Behavior/Parse Tree
module [0, 0] - [2, 0] function_definition [0, 0] - [1, 12] name: identifier [0, 4] - [0, 11] parameters: parameters [0, 11] - [0, 17] identifier [0, 12] - [0, 16] return_type: type [0, 21] - [0, 36] boolean_operator [0, 21] - [0, 36] left: subscript [0, 21] - [0, 28] value: identifier [0, 21] - [0, 22] subscript: identifier [0, 23] - [0, 27] right: none [0, 32] - [0, 36] body: block [1, 4] - [1, 12] return_statement [1, 4] - [1, 12] integer [1, 11] - [1, 12]
Repro