-
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
Normative: Allow initializers in ForInStatement heads #614
Conversation
We may also want to amend the line-item in Annex E which describes this production.
|
The current note in Annex E is actually wrong; the value was not discarded and was observable if the object had no properties or if the rhs I'm not sure if Annex E is maintaining a running list of changes between all version, or only changes between the current version and previous versions. If the former, I propose we append "In ECMAScript 2017, this is only disallowed in strict mode code." If the latter, it should instead read
|
Oh, also: it would be helpful if the section that this extension concerns included a reference, like in Runtime Semantics: PropertyDefinitionEvaluation |
@jugglinmike, this extension augments 8 different sections, mostly in trivial ways (i.e. adding the new production to the list of possible |
It may be sufficient to document the extension in a NOTE for The for-in and for-of Statements. Personally, I think duplicating the note in relevant sections would be preferable, though. Still a third option would be to write all of this text in the main specification itself, and then introduce an early SyntaxError for it that could be disabled by Annex B. I think there is some precedent for disabled grammar like this; the ArrowParameters supports Whatever the case, my motivation is discoverability. I've been surprised by annex B extensions in the past, and I think an explicit reference from the "mainline" text is helpful in avoiding this (I'm proposing an unrelated one in gh-607). I'm sure @bterlson and @allenwb have a much clearer idea of how this ought to be executed. |
I like @jugglinmike 's idea of a NOTE. For tc39/ecma402#84 , the plan is to make a new facility in 402 to write the compatibilty fix in-line, but still marked as normative-optional. Maybe we should consider doing something like that in 262 as well if it works well for that change. This would be a purely editorial and not semantic change. |
LabelledStatement has a better example of the "restricted grammar" approach I suggested above:
|
That seems reasonable, though I find it a little odd to give static and runtime semantics in the main text for a production which is forbidden unless Annex B is applied. This is how labelled function declarations are done. I'm going to hold off rewriting it pending more feedback. It'll be fairly straightforward either way. |
I am not sure what the intent of Annex E is either. I think there is value in keeping a running list, though, so unless there are objections, let's go with that! Should update the Annex E copy to be more accurate. @bakkot I like your copy, want to add it to this PR? In terms of whether to do a note in all the relevant sections, write the spec text inline, or use the nascent 402 convention for normative-optional, I'm ok with just doing the notes (in all the relevant places). I don't mind the labeled function declaration convention for small things, but I'm not much a fan of adding a ton of semantics that aren't used unless an annex B extension is in play. @bakkot want to just add the notes? Then this should be good to go. |
d006120
to
b482c98
Compare
@bterlson, I've added notes to all affected sections and updated the note in Annex E (with a slightly different wording than proposed above). |
We can maybe get away with doing this only in sloppy mode, since that's what Chrome's currently shipping. |
I'm never really seen the need to drop it at all. It seems like a lot of On Jul 22, 2016 5:54 PM, "Kevin Gibbons" [email protected] wrote:
|
We have consensus for this, modulo: should only be allowed in strict mode, needs test262 collateral. |
Fixes chakra-core#1340 and is the result of tc39/ecma262#614
These were re-introduced in sloppy mode per tc39/ecma262#614
These were re-introduced in sloppy mode per tc39/ecma262#614
I've added tests. The spec text as written only adds the new production in non-strict code (although I invite people who have written more spec text to review that). |
I haven't looked at the spec text (so maybe this is in there), but want to emphasize that we should also disallow let/const and destructuring for var. That is, we should only allow |
I think we can get away with this restriction because this has been JSC's behavior for a long time. |
saambarati, that is indeed the case - see slides. |
These were re-introduced in sloppy mode per tc39/ecma262#614
These were re-introduced in sloppy mode per tc39/ecma262#614
These were re-introduced in sloppy mode per tc39/ecma262#614
These were re-introduced in sloppy mode per tc39/ecma262#614
The tests are merged. |
* upstream/master: (301 commits) Editorial: remove mistakenly committed change to eval-related super errors Normative: Point to the latest version of UTR15 (tc39#681) Meta: update ecmarkup version dependency (tc39#682) Editorial: Update a variable name in Annex B.3.3.1 to refer to the proper variable in FunctionDeclarationInstantiation's body, and add warning comments by all the spec algorithms monkey-patched by Annex B so that future refactoring doesn't create broken/dangling references in Annex B. (tc39#677) Meta: update ecmarkup version dependency Editorial: dfn-ify 'goal symbol' Editorial: TypeArray -> TypedArray (tc39#675) Editorial: Correct a wrong cross-reference in Annex C (tc39#674) Editorial: tweak whitespace and articles (tc39#667) Editorial: Tweak EnumerateObjectProperties informative definition (tc39#656) Editorial: Rename variable (indx --> index) (tc39#658) Editorial: Fix reference in ScriptEvaluation (tc39#659) Editorial: Consistent `undefined or null` order (tc39#660) Editorial: Refactor Array.prototype.toLocaleString (tc39#662) Editorial: Tweak Array.prototype.join (tc39#661) Simplify description of CreateImmutableBinding (tc39#654) Normative: Resolve template argument references (tc39#609) Editorial: Refactor Array.prototype.join (tc39#638) Editorial: contains --> Contains in ModuleListItem SS Normative: Allow initializers in ForInStatement heads (tc39#614) ...
PR tc39#614 defined (in Annex B) an additional form for ForInOfStatement. Performing ForInOfLoopEvaluation on it ends with a call to ForIn/OfBodyEvaluation, with |BindingIdentifier| as first arg, passed to the _lhs_ param. ForIn/OfBodyEvaluation (at step 6.g.i.1) evaluates this param, but there's no definition of Evaluation for |BindingIdentifier|. This PR adds the necessary definition. (The new definition basically just duplicates the one for ForBinding. In fact, if this part of Annex B is merged into the main spec, the definition for ForBinding can be dropped, since it can just chain to this new definition.)
PR tc39#614 defined (in Annex B) an additional form for ForInOfStatement. Performing ForInOfLoopEvaluation on it ends with a call to ForIn/OfBodyEvaluation, with |BindingIdentifier| as first arg, passed to the _lhs_ param. ForIn/OfBodyEvaluation (at step 6.g.i.1) evaluates this param, but there's no definition of Evaluation for |BindingIdentifier|. This PR adds the necessary definition. (The new definition basically just duplicates the one for ForBinding. In fact, if this part of Annex B is merged into the main spec, the definition for ForBinding can be dropped, since it can just chain to this new definition.)
PR tc39#614 defined (in Annex B) an additional form for ForInOfStatement. Performing ForInOfLoopEvaluation on it ends with a call to ForIn/OfBodyEvaluation, with |BindingIdentifier| as first arg, passed to the _lhs_ param. ForIn/OfBodyEvaluation (at step 6.g.i.1) evaluates this param, but there's no definition of Evaluation for |BindingIdentifier|. This PR adds the necessary definition. Rather than add it to the annex that defines the additional form of ForInOfStatement, this commit substitutes it for the (main body) definition of `Evaluation` for `ForBinding : BindingIdentifier`, allowing the latter to chain to the new definition, since it has the same semantics.
PR tc39#614 defined (in Annex B) an additional form for ForInOfStatement. Performing ForInOfLoopEvaluation on it ends with a call to ForIn/OfBodyEvaluation, with |BindingIdentifier| as first arg, passed to the _lhs_ param. ForIn/OfBodyEvaluation (at step 6.g.i.1) evaluates this param, but there's no definition of Evaluation for |BindingIdentifier|. This PR adds the necessary definition. Rather than add it to the annex that defines the additional form of ForInOfStatement, this commit substitutes it for the (main body) definition of `Evaluation` for `ForBinding : BindingIdentifier`, allowing the latter to chain to the new definition, since it has the same semantics.
PR tc39#614 defined (in Annex B) an additional form for ForInOfStatement. Performing ForInOfLoopEvaluation on it ends with a call to ForIn/OfBodyEvaluation, with |BindingIdentifier| as first arg, passed to the _lhs_ param. ForIn/OfBodyEvaluation (at step 6.g.i.1) evaluates this param, but there's no definition of Evaluation for |BindingIdentifier|. This PR adds the necessary definition. Rather than add it to the annex that defines the additional form of ForInOfStatement, this commit substitutes it for the (main body) definition of `Evaluation` for `ForBinding : BindingIdentifier`, allowing the latter to chain to the new definition, since it has the same semantics.
Fixes #260.
Per discussion, this adds a section in Annex B with a production for
for ( var BindingIdentifier Initializer in Expression) Statement
with its original semantics, in light of the usage statistics collected by V8 and the fact that implementers have had to allow this production.Edit (July 27, 2016): This comment was slightly wrong; it was only added to non-strict code.