Open SubhamPramanik opened 4 months ago
@hendrikvanantwerpen For visibility. Thanks!
I was about to report the same issue.
My example is
a = 1
b = 2
c = b = a
The tree-sitter CST for this is
(module [0, 0] - [3, 0]
(expression_statement [0, 0] - [0, 5]
(assignment [0, 0] - [0, 5]
left: (identifier [0, 0] - [0, 1])
right: (integer [0, 4] - [0, 5])))
(expression_statement [1, 0] - [1, 5]
(assignment [1, 0] - [1, 5]
left: (identifier [1, 0] - [1, 1])
right: (integer [1, 4] - [1, 5])))
(expression_statement [2, 0] - [2, 9]
(assignment [2, 0] - [2, 9]
left: (identifier [2, 0] - [2, 1])
right: (assignment [2, 4] - [2, 9]
left: (identifier [2, 4] - [2, 5])
right: (identifier [2, 8] - [2, 9])))))
The expression c = b = a
results in a nested assignment, which causes the stanza to fail because the syntax node type assignment
does not have an output
attribute.
The suggested fix is to modify this stanza as follows
[
; expressions
++ (assignment)
(comparison_operator)
(not_operator)
(boolean_operator)
; ...
] @node {
node @node.input
node @node.new_bindings
node @node.output
}
Python code:
The following Stanza fails:
Error thrown:
I believe that the TS query is not able to work with chained assignments since the first occurrence of right is incorrect.