Closed
Bug 462385
Opened 16 years ago
Closed 16 years ago
Strange scoping with "for each (let ... in ...)"
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: jruderman, Unassigned)
Details
js> x = 3; for each (let x in [x]) { print(x) }
undefined
I think it should print 3.
Comment 1•16 years ago
|
||
Dup of bug 344952? Is the let here semantically equivalent to a let ... statement (what I assume) or to a let (...) ... statement? mrbkap?
Comment 2•16 years ago
|
||
No, this is a real bug. In the for-in loop and variants, the scope of a let in the LHS if in should not open over the RHS evaluation, only over the body. In a C-style for(let x=...;...;...) loop the scope should open over the condition and update parts only, not the initializer for x.
Blake, you game to take this?
/be
Comment 3•16 years ago
|
||
var o = { x: "out of let" };
let (o = { y: function () { return o.x; }, x: "rhs of let" }) alert(o.y());
This outputs "rhs of let". Is this behavior the same bug as this bug or should I file a new bug?
Comment 4•16 years ago
|
||
(In reply to comment #3)
> var o = { x: "out of let" };
> let (o = { y: function () { return o.x; }, x: "rhs of let" }) alert(o.y());
>
> This outputs "rhs of let". Is this behavior the same bug as this bug or should
> I file a new bug?
Indeed this bug is fixed, probably by upvar2, in my tm build, also in m-c and (I bet) in 1.9.1:
js> x = 3; for each (let x in [x]) { print(x) }
3
So please file comment 3 as a new bug. Thanks,
/be
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Reporter | ||
Updated•16 years ago
|
Flags: in-testsuite?
Comment 5•16 years ago
|
||
I filed bug 500909 for comment 3.
You need to log in
before you can comment on or make changes to this bug.
Description
•