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
Notice that the expression_statement which points to the text 1 is not a child of the return_statement.
This gets especially weird for the parent's bounding box as in this example the if_statement is selected but is not known to include the return value
This seems to also affect break and continue statements capturing their labels
ie bar here should be considered a label as a statement_identifier but isnt and instead is an expression_statement
functionfoo(){while(true){if(true)break/**/ bar
}}
It seems like what's happening here is: If you have a statement in a statement block that can end early (ie it ends with optionals). Then an in-line comment can trick the parser into thinking the statement has ended early and leave the now-unaccounted-for optional suffix to be considered distinct expressions statements.
The text was updated successfully, but these errors were encountered:
The following piece of code is valid but it is parsed incorrectly:
Here's a link to the TypeScript Playground showing that the snippet above is valid JavaScript or TypeScript:
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABMOcAUBKRBvAUIgxAJwFMoQikB6AKhqsQEYBuXAXyA
The output of
tree-sitter parse
is the following:Notice that the
expression_statement
which points to the text1
is not a child of thereturn_statement
.This gets especially weird for the parent's bounding box as in this example the
if_statement
is selected but is not known to include the return valueThis seems to also affect
break
andcontinue
statements capturing their labelsie
bar
here should be considered alabel
as astatement_identifier
but isnt and instead is anexpression_statement
It seems like what's happening here is: If you have a statement in a statement block that can end early (ie it ends with optionals). Then an in-line comment can trick the parser into thinking the statement has ended early and leave the now-unaccounted-for optional suffix to be considered distinct expressions statements.
The text was updated successfully, but these errors were encountered: