You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A program that tracks the meaning of variables can usually work like this:
Recursive traversal through the TSNode tree.
When encountering a var_declaration, const_declaration, or short_var_declaration, take note of the variables in these declarations, which have a scope that lasts until the end of the current recursion level.
But for the short_var_declaration in a for statement (cf. https://go.dev/ref/spec#For_statements), it does not work, because what tree-sitter returns has the structure
Here the program has to special-case for_statement and pull out the initializer field from the for_clause. This is cumbersome. It would be simpler if tree-sitter returned a structure like this:
A program that tracks the meaning of variables can usually work like this:
var_declaration
,const_declaration
, orshort_var_declaration
, take note of the variables in these declarations, which have a scope that lasts until the end of the current recursion level.This simple algorithm works fine
short_var_declaration
inif
andswitch
statements (cf. https://go.dev/ref/spec#If_statements and https://go.dev/ref/spec#Switch_statements).But for the
short_var_declaration
in afor
statement (cf. https://go.dev/ref/spec#For_statements), it does not work, because what tree-sitter returns has the structureHere the program has to special-case
for_statement
and pull out theinitializer
field from thefor_clause
. This is cumbersome. It would be simpler if tree-sitter returned a structure like this:How to reproduce:
Process this input file:
The syntax tree that tree-sitter produces is:
The text was updated successfully, but these errors were encountered: