Closed
Bug 1306701
Opened 9 years ago
Closed 9 years ago
Allow initializers in ForInStatement heads
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla52
Tracking | Status | |
---|---|---|
firefox52 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
Details
Attachments
(3 files, 3 obsolete files)
4.34 KB,
patch
|
anba
:
review+
|
Details | Diff | Splinter Review |
7.08 KB,
patch
|
anba
:
review+
|
Details | Diff | Splinter Review |
12.52 KB,
patch
|
anba
:
review+
|
Details | Diff | Splinter Review |
TC39 has revived this syntax for ES2017.
Assignee | ||
Comment 1•9 years ago
|
||
AFAICT this code in BytecodeEmitter::emitDeclarationList is dead, so we can simply remove it. Can you confirm?
Attachment #8796670 -
Flags: review?(jwalden+bmo)
Assignee | ||
Comment 2•9 years ago
|
||
Just inlined and removed emitDestructuringOpsHelper
Attachment #8796672 -
Flags: review?(jwalden+bmo)
Assignee | ||
Comment 3•9 years ago
|
||
The actual patch.
Attachment #8796673 -
Flags: review?(jwalden+bmo)
Comment 4•9 years ago
|
||
Comment on attachment 8796670 [details] [diff] [review]
bug1306701.part01.patch
Review of attachment 8796670 [details] [diff] [review]:
-----------------------------------------------------------------
Yeah, I think this is right. But, punting to shu for the quick double-check.
Attachment #8796670 -
Flags: review?(shu)
Attachment #8796670 -
Flags: review?(jwalden+bmo)
Attachment #8796670 -
Flags: review+
Updated•9 years ago
|
Attachment #8796672 -
Flags: review?(jwalden+bmo) → review+
Comment 5•9 years ago
|
||
Comment on attachment 8796673 [details] [diff] [review]
bug1306701.part1.patch
Review of attachment 8796673 [details] [diff] [review]:
-----------------------------------------------------------------
The terrorists have won. :-(
(Or, more precisely, the people who think that if you can't change something *now*, that's already rare, you'll never ever ever be able to wait it out and remove it eventually. Bah.)
::: js/src/frontend/BytecodeEmitter.cpp
@@ +6019,5 @@
> + MOZ_ASSERT(forInTarget->isKind(PNK_VAR),
> + "for-in initializer expression only valid for |var| declarations");
> +
> + if (!emitDeclarationList(forInTarget))
> + return false;
Given what we know, very specifically, about the declaration here, I think I'd prefer more-precise actions be taken, than going through emitDeclarationList. It also seems valuable to keep this edge-case handling, *in* this edge case, rather than requiring generalized declaration-list handling to deal with it, forevermore.
// Annex B: Evaluate the var-initializer expression if present.
// |for (var i = initializer in expr) { ... }|
ParseNode* forInTarget = forInHead->pn_kid1;
if (parser->handler.isDeclarationList(forInTarget)) {
ParseNode* decl = parser->handler.singleBindingFromDeclaration(forInTarget);
if (decl->isKind(PNK_NAME)) {
if (ParseNode* initializer = decl->expr()) {
MOZ_ASSERT(forInTarget->isKind(PNK_VAR),
"for-in initializers are only permitted for |var| "
"declarations");
auto emitRhs = [initializer](BytecodeEmitter* bce, const NameLocation&, bool) {
return bce->emitTree(initializer);
};
if (!emitInitializeName(decl, emitRhs))
return false;
// Pop the initializer.
if (!emit1(JSOP_POP))
return false;
}
}
}
::: js/src/tests/ecma_6/extensions/for-in-with-assignments.js
@@ -1,1 @@
> -/*
Please rerecord this as a move from this location to the other one -- clearly most of it's the same and only a few bits are different, and those differences are the important part.
If you are one of the haters using git instead of Mercurial, know that Mercurial as functional VCS supports proper file moving, and you may have to perform the |hg mv ecma_6/extensions/for-in-with-assignment.js ecma_8/Statements/for-in-with-assignments.js| in a Mercurial repository, not a git repository.
::: js/src/tests/ecma_8/Statements/for-in-with-assignment-syntax.js
@@ +21,5 @@
> + " {x = 0}",
> +];
> +
> +const invalidSyntax = [
> + ...destructuring.map(binding => `var {binding}`),
Uh, don't you mean ${binding}? And in the other two.
Attachment #8796673 -
Flags: review?(jwalden+bmo) → review+
Assignee | ||
Comment 6•9 years ago
|
||
(In reply to Jeff Walden [:Waldo] (remove +bmo to email) from comment #5)
> The terrorists have won. :-(
https://www.youtube.com/watch?v=v5cBkhYBVt8
> ::: js/src/tests/ecma_6/extensions/for-in-with-assignments.js
> @@ -1,1 @@
> > -/*
>
> If you are one of the haters using git instead of Mercurial, know that
> Mercurial as functional VCS supports proper file moving, [...].
Lalala, don't hear you! :-D
Comment 7•9 years ago
|
||
Comment on attachment 8796670 [details] [diff] [review]
bug1306701.part01.patch
Review of attachment 8796670 [details] [diff] [review]:
-----------------------------------------------------------------
Indeed, old SM-style comprehensions are dead.
Attachment #8796670 -
Flags: review?(shu) → review+
Assignee | ||
Comment 8•9 years ago
|
||
Update reviewers for patch part 0.1
Attachment #8796670 -
Attachment is obsolete: true
Attachment #8799464 -
Flags: review+
Assignee | ||
Comment 9•9 years ago
|
||
Update patch part 0.2 to apply cleanly on inbound. Carrying r+ from Waldo.
Attachment #8796672 -
Attachment is obsolete: true
Attachment #8799465 -
Flags: review+
Assignee | ||
Comment 10•9 years ago
|
||
Update patch part 1 to address review comments. Carrying r+ from Waldo.
Attachment #8796673 -
Attachment is obsolete: true
Attachment #8799468 -
Flags: review+
Assignee | ||
Comment 11•9 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=921e413c5b16a228cfaa65a543ee84381261867e
Keywords: checkin-needed
Comment 12•9 years ago
|
||
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/9d4004121f9c
Part 0.1: Remove dead code in BytecodeEmitter::emitDeclarationList. r=Waldo, shu
https://hg.mozilla.org/integration/mozilla-inbound/rev/d4c1417d3155
Part 0.2: Remove no longer needed destructuring helper method from BytecodeEmitter. r=Waldo
https://hg.mozilla.org/integration/mozilla-inbound/rev/86e17a8b40d0
Part 1: Evaluate var-initializer expression in for-in loop per Annex B.3.6 (ES2017). r=Waldo
Keywords: checkin-needed
Comment 13•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/9d4004121f9c
https://hg.mozilla.org/mozilla-central/rev/d4c1417d3155
https://hg.mozilla.org/mozilla-central/rev/86e17a8b40d0
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
You need to log in
before you can comment on or make changes to this bug.
Description
•