Closed
Bug 1069480
Opened 10 years ago
Closed 8 years ago
Update for- and for-in/of TDZ rules to match latest spec
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: anba, Assigned: Waldo)
References
Details
(Whiteboard: [v8api])
Expected: ReferenceError thrown when calling the various test* functions
Actual: No ReferenceError thrown
function testForOfRhs() {
let x = "outer";
for (let x of [x]) print(x);
}
testForOfRhs();
function testForOfComputed() {
let x = "outer";
for (let {[x]: x} of [{outer: 123}]) {
print(x)
}
}
testForOfComputed();
function testForInRhs() {
let x = "outer";
for (let x in {key: x}) print(x);
}
testForInRhs();
function testForInComputed() {
let x = "0";
for (let {[x]: x} in {key: 123}) {
print(x)
}
}
testForInComputed();
function testForRhs() {
let x = "outer";
for (let x = x;;) {
print(x);
break;
}
}
testForRhs()
function testForComputed() {
let x = "outer";
for (let {[x]: x} = {outer: 123};;) {
print(x);
break;
}
}
testForComputed();
Assignee | ||
Comment 2•10 years ago
|
||
Another fun addition I seem to have discovered in reading the semantics for this stuff just now:
var item;
for (let x of [function() { x; }])
item = x;
// This is a TDZ violation as far as I can tell: |x;| refers to
// an x in the loop-head, not an x for an iteration of the loop.
item();
I don't believe this changes the implementability of anything (or at least it seems like it shouldn't, in advance of implementation) -- but it is a rather odd bit of behavior.
Updated•9 years ago
|
Assignee: winter2718 → nobody
Updated•8 years ago
|
Whiteboard: [v8api]
Assignee | ||
Comment 5•8 years ago
|
||
I have a PR against the Github repo/branch where bug 1263355 is being worked on, that I believe fixes this. Don't anybody bother testing it, tho, because there are known cases (e.g. any for-in/of loop with lexical declaration whose body captures one of those lexical declarations) where the PR falls down, because the underlying branch isn't fully completed yet.
https://github.com/syg/gecko-dev/pull/1
Assignee: nobody → jwalden+bmo
Status: NEW → ASSIGNED
Comment 6•8 years ago
|
||
Fixed by bug 1263355.
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•