Bug 685321: detect closed-over variables conservatively, r=jorendorff

This commit is contained in:
Brendan Eich 2011-11-28 11:57:10 -08:00
parent c82af6d14e
commit ef360d317a
2 changed files with 13 additions and 0 deletions

View File

@ -673,6 +673,8 @@ Define(ParseNode *pn, JSAtom *atom, TreeContext *tc, bool let = false)
if ((!pnu || pnu->pn_blockid < tc->bodyid) && foundLexdep)
tc->lexdeps->remove(atom);
}
pn->pn_dflags |= dn->pn_dflags & PND_CLOSED;
}
Definition *toAdd = (Definition *) pn;

View File

@ -0,0 +1,11 @@
function f() {
function g() {
for (var i = 0; i < 3; i++)
x = i;
};
var [x] = 0;
g();
assertEq(x, 2);
print(x);
}
f();