Bug 886803 - Populate both script and function box bindings for new Function() functions, so heavyweight tests work. r=jandem, a=bajaj
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -860,18 +860,25 @@ Parser<FullParseHandler>::standaloneFunc
if (!tokenStream.matchToken(TOK_EOF)) {
report(ParseError, false, null(), JSMSG_SYNTAX_ERROR);
return null();
}
if (!FoldConstants(context, &pn, this))
return null();
- InternalHandle<Bindings*> bindings(script, &script->bindings);
- if (!funpc.generateFunctionBindings(context, bindings))
+ InternalHandle<Bindings*> scriptBindings(script, &script->bindings);
+ if (!funpc.generateFunctionBindings(context, scriptBindings))
+ return null();
+
+ // Also populate the internal bindings of the function box, so that
+ // heavyweight tests while emitting bytecode work.
+ InternalHandle<Bindings*> funboxBindings =
+ InternalHandle<Bindings*>::fromMarkedLocation(&(*funbox)->bindings);
+ if (!funpc.generateFunctionBindings(context, funboxBindings))
return null();
return pn;
}
template <>
bool
Parser<FullParseHandler>::checkFunctionArguments()
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug886803.js
@@ -0,0 +1,3 @@
+
+f = Function("with({}) { var i; }");
+f();