diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index 487ddf78dbf..13077a4e06e 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -5848,13 +5848,6 @@ Parser::generatorExpr(ParseNode *kid) genfn->pn_pos.begin = body->pn_pos.begin = kid->pn_pos.begin; genfn->pn_pos.end = body->pn_pos.end = tokenStream.currentToken().pos.end; - if (AtomDefnPtr p = genpc.lexdeps->lookup(context->names().arguments)) { - Definition *dn = p.value(); - ParseNode *errorNode = dn->dn_uses ? dn->dn_uses : body; - report(ParseError, false, errorNode, JSMSG_BAD_GENEXP_BODY, js_arguments_str); - return null(); - } - RootedPropertyName funName(context); if (!leaveFunction(genfn, funName)) return null(); diff --git a/js/src/jit-test/tests/arguments/genexpr-1.js b/js/src/jit-test/tests/arguments/genexpr-1.js new file mode 100644 index 00000000000..edac127239e --- /dev/null +++ b/js/src/jit-test/tests/arguments/genexpr-1.js @@ -0,0 +1,7 @@ +// No 'arguments' binding in genexprs at toplevel. + +load(libdir + "asserts.js"); + +delete this.arguments; // it is defined in the shell +var iter = (arguments for (x of [1])); +assertThrowsInstanceOf(() => iter.next(), ReferenceError); diff --git a/js/src/jit-test/tests/arguments/genexpr-2.js b/js/src/jit-test/tests/arguments/genexpr-2.js new file mode 100644 index 00000000000..7d99a7df124 --- /dev/null +++ b/js/src/jit-test/tests/arguments/genexpr-2.js @@ -0,0 +1,4 @@ +// 'arguments' is lexically scoped in genexprs at toplevel. + +var arguments = 8; +assertEq((arguments for (x of [1])).next(), 8); diff --git a/js/src/jit-test/tests/arguments/genexpr-3.js b/js/src/jit-test/tests/arguments/genexpr-3.js new file mode 100644 index 00000000000..5441aeb5824 --- /dev/null +++ b/js/src/jit-test/tests/arguments/genexpr-3.js @@ -0,0 +1,6 @@ +// 'arguments' is lexically scoped in genexpr in toplevel let-block. + +{ + let arguments = []; + assertEq((arguments for (p in {a: 1})).next(), arguments); +} diff --git a/js/src/jit-test/tests/arguments/genexpr-4.js b/js/src/jit-test/tests/arguments/genexpr-4.js new file mode 100644 index 00000000000..95e34a099ff --- /dev/null +++ b/js/src/jit-test/tests/arguments/genexpr-4.js @@ -0,0 +1,7 @@ +// 'arguments' is lexically scoped in genexpr in function. + +function f() { + assertEq((arguments for (x of [0])).next(), + (arguments for (y of [1])).next()); +} +f(); diff --git a/js/src/jit-test/tests/arguments/genexpr-5.js b/js/src/jit-test/tests/arguments/genexpr-5.js new file mode 100644 index 00000000000..7dc74091e58 --- /dev/null +++ b/js/src/jit-test/tests/arguments/genexpr-5.js @@ -0,0 +1,8 @@ +// 'arguments' binding can be closed over and outlives the function activation. + +function f() { + return (arguments for (x of [1])); +} + +var args = f("ponies").next(); +assertEq(args[0], "ponies"); diff --git a/js/src/jit-test/tests/arguments/genexpr-6.js b/js/src/jit-test/tests/arguments/genexpr-6.js new file mode 100644 index 00000000000..9470f3dcb71 --- /dev/null +++ b/js/src/jit-test/tests/arguments/genexpr-6.js @@ -0,0 +1,12 @@ +// 'arguments' works in nested genexprs. + +function f() { + return ((((((arguments for (u of [0])) + for (v of [1])) + for (w of [2])) + for (x of [3])) + for (y of [4])) + for (z of [5])); +} +var args = f("ponies").next().next().next().next().next().next(); +assertEq(args[0], "ponies"); diff --git a/js/src/jit-test/tests/basic/bug660538.js b/js/src/jit-test/tests/basic/bug660538.js index ccbf489c3d7..ae854cd7589 100644 --- a/js/src/jit-test/tests/basic/bug660538.js +++ b/js/src/jit-test/tests/basic/bug660538.js @@ -1,5 +1,3 @@ -// |jit-test| error: SyntaxError; - Error.prototype.__proto__.p = 5; f = Function("return( \"\"