-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrectly parsed labeled statement #259
Comments
this one would be really really hard to fix w/o a mechanism to disallow rules in certain contexts (objects in expression statements in if statements) |
Poking at this a little bit, it seems a bit more general than just this I think the fundamental thing that's currently not being enforced by the grammar is (from the ECMAScript standard):
So eg the
are incorrect parsing currently I don't think I probably have a good enough grasp of tree-sitter grammars to take a crack at this myself. But it seems like maybe you'd need eg |
So most statements cannot have an object literal? Interesting |
Ya statements can't start with an object literal (or object-destructuring pattern) I vaguely recall that from working in JS/Typescript that say you wanted to object-destructure into an existing variable you'd have to wrap in parentheses to avoid the "leading
|
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/JYMwBAFCD20JRgN5gEYEMBOAuMBydAXrmAL5A
The output of
tree-sitter parse
is the following:It looks like this should be parsing as a block with a labeled statement but it is parsing as an object literal
The text was updated successfully, but these errors were encountered: