Closed Bug 462385 Opened 16 years ago Closed 16 years ago

Strange scoping with "for each (let ... in ...)"

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

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.
Dup of bug 344952? Is the let here semantically equivalent to a let ... statement (what I assume) or to a let (...) ... statement? mrbkap?
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
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?
(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
Flags: in-testsuite?
You need to log in before you can comment on or make changes to this bug.