Closed Bug 352921 Opened 18 years ago Closed 11 years ago

Label misplaced after hoisting with "L: for(var i = x in w)"

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED

People

(Reporter: jruderman, Unassigned)

Details

(Keywords: testcase)

js> function() { L: for(let i = x in w) break L }
function () {
L:
    x;
    for (let i in w) {
        break L;
    }
}

(Is this the only construct that causes a statement to be hoisted, or are there others?)
The problem is more clear with "continue" than "break", because you can only continue to a loop.
Yes, only in the bizarre case of an initializer for a for-in variable do we hoist the initalizer (and the var; let must remain in the loop of course), to simplify the source annotations needed for decompilation.

This is a minor bug.

/be
Severity: normal → minor
Something similar happens with |var|:

js> function() { L: for(var i = x in w) break L } 
function () {
L:
    var i = x;
    for (i in w) {
        break L;
    }
}
Comment #0 now gives:
js> (function() { L: for(let i = x in w) break L })
typein:23: SyntaxError: for-in loop let declaration may not have an initializer:
typein:23: (function() { L: for(let i = x in w) break L })
typein:23: .........................^

Comment #3 still shows the bug.
OS: Mac OS X → All
Hardware: PowerPC → All
BytecodeEmitter.cpp: "'for (let x = i in o)' is mercifully banned."
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → INVALID
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Summary: Label misplaced after hoisting with "L: for(let i = x in w)" → Label misplaced after hoisting with "L: for(var i = x in w)"
Fixed by saving the source (bug 761723).
Status: REOPENED → RESOLVED
Closed: 12 years ago11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.