-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Annex B 3: FunctionDeclaration in LabelledStatement in, e.g., IterationStatement? #480
Comments
Thanks @allenwb ! That resolves it; I guess this is the same as my first option. |
All of Firefox, Chrome, Safari, and Edge currently still allow labelled function declarations under if, with, and loop statements in sloppy mode. Do we know for sure if this is web compatible? I strongly suspect yes, but it seems like we still don't know. Please re-close if there is an actual shipping implementation of this. |
I completely tested the wrong thing, and I am sorry for alerting people. |
With all of Annex B 3 in effect, it seems like the syntax permits statements like this in sloppy mode:
This is based on Annex B 3.2 https://tc39.github.io/ecma262/#sec-functiondeclarations-in-ifstatement-statement-clauses, which permits FunctionDeclarations as the LabelledItem in a LabelledStatement in sloppy mode. LabelledStatements are Statements, so they are permitted as the body of an IterationStatement.
What are the semantics of such a usage? The only guide I see is Annex B 3.4 https://tc39.github.io/ecma262/#sec-functiondeclarations-in-ifstatement-statement-clauses which says that FunctionDeclarations as the body of an IfStatement act like they are enclosed in a block. But I don't see any of this logic for LabelledStatements.
I see a couple possibilities:
Based on the general design of Annex B, trying to be minimal, I think we might want to go with the first option. Thoughts?
@bterlson @allenwb @jugglinmike
The text was updated successfully, but these errors were encountered: