-
Notifications
You must be signed in to change notification settings - Fork 592
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
[JavaScript] Refactor statements. #1469
[JavaScript] Refactor statements. #1469
Conversation
…hom1729/Packages into javascript-refactor-statements
…hom1729/Packages into javascript-refactor-statements
…hom1729/Packages into javascript-refactor-statements
@wbond FYI, this does fix a fairly visible bug with |
I am going to do another pass through the packages before the next dev build, so I should be able to get this in |
I'm definitely not keen on the |
…tatements [JavaScript] Refactor statements.
This PR does for statements what #1009 did for expressions. Fortunately, this is a much, much simpler change.
This change:
meta.import|export
.punctuation.terminator.statement.empty
. (These semicolons are usually unwanted.) This will make it much easier to write sensible tests for statements that do not require a semicolon.of
/in
keyword infor
loops, which was apparently broken. There are some corner cases that aren't handled perfectly, and in fact distinguishing the two types of for loops perfectly is impossible in Sublime (like distinguishing arrow functions from parenthesized expressions). The new code for this should do the right thing in reasonable cases and fail gracefully elsewhere.switch
anddo-while
.In addition, it fixes a parsing problem with commas in exports that was visible in JS Custom. The core syntax scopes the rare JavaScript comma operator as punctuation, so the problem was not observable in the core syntax. However, this fix lets us implement #831 if we want to.
As a result of this change, we do have a lot of anonymous contexts providing meta scopes:
These contexts are not reusable, and in my opinion they're easier to understand "inline" rather than factored out. Opinions may vary on this.