зеркало из https://github.com/mozilla/gecko-dev.git
Bug 753158 - Don't resolve uses to defs that cross non-top-level function statements (r=dvander)
--HG-- extra : rebase_source : 36331b2b862186f224c2edaf3d9a8d23a079269a
This commit is contained in:
Родитель
86ec4d2f17
Коммит
1299e77cea
|
@ -1143,10 +1143,10 @@ LeaveFunction(ParseNode *fn, Parser *parser, PropertyName *funName = NULL,
|
|||
|
||||
/*
|
||||
* Make sure to deoptimize lexical dependencies that are polluted
|
||||
* by eval (approximated by bindingsAccessedDynamically) or with, to
|
||||
* safely bind globals (see bug 561923).
|
||||
* by eval and function statements (which both flag the function as
|
||||
* having an extensible scope) or any enclosing 'with'.
|
||||
*/
|
||||
if (funtc->sc->bindingsAccessedDynamically() ||
|
||||
if (funtc->sc->funHasExtensibleScope() ||
|
||||
(outer_dn && tc->innermostWith &&
|
||||
outer_dn->pn_pos < tc->innermostWith->pn_pos)) {
|
||||
DeoptimizeUsesWithin(dn, fn->pn_pos);
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
function testFuncStmt1() {
|
||||
var g = 3;
|
||||
function f(b) {
|
||||
if (b) {
|
||||
function g() { return 42 }
|
||||
assertEq(g(), 42);
|
||||
}
|
||||
}
|
||||
f(true);
|
||||
}
|
||||
testFuncStmt1();
|
||||
|
||||
function testFuncStmt2() {
|
||||
var g = 3;
|
||||
(function(b) {
|
||||
if (b) {
|
||||
function g() { return 42 }
|
||||
function f() { assertEq(g(), 42); }
|
||||
f();
|
||||
}
|
||||
})(true);
|
||||
}
|
||||
testFuncStmt2();
|
||||
|
||||
function testEval1() {
|
||||
var g = 3;
|
||||
function f() {
|
||||
eval("var g = 42");
|
||||
assertEq(g, 42);
|
||||
}
|
||||
f();
|
||||
}
|
||||
testEval1();
|
||||
|
||||
function testEval2() {
|
||||
var g = 3;
|
||||
(function() {
|
||||
eval("var g = 42");
|
||||
function f() {
|
||||
assertEq(g, 42);
|
||||
}
|
||||
f();
|
||||
})();
|
||||
}
|
||||
testEval2();
|
||||
|
||||
function testWith1() {
|
||||
var g = 3;
|
||||
function f() {
|
||||
with ({g:42}) {
|
||||
assertEq(g, 42);
|
||||
}
|
||||
}
|
||||
f();
|
||||
}
|
||||
testWith1();
|
||||
|
||||
function testWith2() {
|
||||
var g = 3;
|
||||
with ({g:42}) {
|
||||
function f() {
|
||||
assertEq(g, 42);
|
||||
}
|
||||
}
|
||||
f();
|
||||
}
|
||||
testWith2();
|
Загрузка…
Ссылка в новой задаче