Bug 780405 - Set the funbox kids in LeaveFunction, so generator expression boxes don't lose them. r=jorendorff
authorBenjamin Peterson <benjamin@python.org>
Tue, 07 Aug 2012 13:41:31 -0700
changeset 101716 84739a192aa9baf5f1332d2a6b5f77d7ad2f1a53
parent 101715 e2d35dd85c62253c6193411d4f85924aff352c96
child 101717 6ee7b6582fbd620af43f71f17525e674e95d73ef
push id23250
push useremorley@mozilla.com
push dateWed, 08 Aug 2012 16:23:03 +0000
treeherdermozilla-central@b99a81e70b06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs780405
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 780405 - Set the funbox kids in LeaveFunction, so generator expression boxes don't lose them. r=jorendorff
js/src/frontend/Parser.cpp
js/src/jit-test/tests/arguments/defaults-strict-mode.js
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -1092,16 +1092,17 @@ LeaveFunction(ParseNode *fn, Parser *par
               FunctionSyntaxKind kind = Expression)
 {
     TreeContext *funtc = parser->tc;
     TreeContext *tc = funtc->parent;
     tc->blockidGen = funtc->blockidGen;
 
     FunctionBox *funbox = fn->pn_funbox;
     funbox->cxFlags = funtc->sc->cxFlags;   // copy all the flags
+    funbox->kids = funtc->functionList;
 
     if (!tc->topStmt || tc->topStmt->type == STMT_BLOCK)
         fn->pn_dflags |= PND_BLOCKCHILD;
 
     /*
      * Propagate unresolved lexical names up to tc->lexdeps, and save a copy
      * of funtc->lexdeps in a TOK_UPVARS node wrapping the function's formal
      * params and body. We do this only if there are lexical dependencies not
@@ -1722,18 +1723,16 @@ Parser::functionDef(HandlePropertyName f
                 if (!outertc->funcStmts || !outertc->funcStmts->init())
                     return NULL;
             }
             if (!outertc->funcStmts->put(funName))
                 return NULL;
         }
     }
 
-    funbox->kids = funtc.functionList;
-
     pn->pn_funbox = funbox;
     pn->setOp(op);
     pn->pn_body->append(body);
     pn->pn_body->pn_pos = body->pn_pos;
 
     JS_ASSERT_IF(!outertc->sc->inFunction() && bodyLevel && kind == Statement,
                  pn->pn_cookie.isFree());
 
--- a/js/src/jit-test/tests/arguments/defaults-strict-mode.js
+++ b/js/src/jit-test/tests/arguments/defaults-strict-mode.js
@@ -4,16 +4,17 @@ function f1(f=(function () { return type
 assertEq(f1()(), true);
 function f2(f=(function () { "use strict"; return (function () { return typeof this !== "object"; }) })) { assertEq(typeof this, "object"); return f; }
 assertEq(f2()()(), true);
 function f3(f=(function () { return (function () { return typeof this !== "object"; }) })) { "use strict"; return f; }
 assertEq(f3()()(), true);
 // These should be okay.
 function f4(f=(function () { with (Object) {} }), g=(function () { "use strict"; })) {}
 function f5(g=(function () { "use strict"; }), f=(function () { with (Object) {} })) {}
+function f6(f=(function () { return (x for (y in (function g() {}))); })) {}
 
 assertThrowsInstanceOf(function () {
     eval("function f(a=delete x) { 'use strict'; }");
 }, SyntaxError);
 assertThrowsInstanceOf(function () {
     Math.sin(4);
     eval("function f(a='\\251') { 'use strict'; }");
 }, SyntaxError);