From 9e809c98e504fbafb39dd83500c5fcdaf7783ddf Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Thu, 11 Apr 2013 16:19:10 -0600 Subject: [PATCH] Bug 855088 - Watch for 'arguments' variables declared within 'with' blocks, r=luke. --- js/src/frontend/Parser.cpp | 16 ++++++++++++++-- js/src/jit-test/tests/basic/bug855088.js | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 js/src/jit-test/tests/basic/bug855088.js diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index 13077a4e06e..355f15644b6 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -2493,8 +2493,20 @@ Parser::bindVarOrConst(JSContext *cx, BindDatatype == STMT_WITH) { pn->pn_dflags |= PND_DEOPTIMIZED; - if (pc->sc->isFunctionBox()) - pc->sc->asFunctionBox()->setMightAliasLocals(); + if (pc->sc->isFunctionBox()) { + FunctionBox *funbox = pc->sc->asFunctionBox(); + funbox->setMightAliasLocals(); + + /* + * This definition isn't being added to the parse context's + * declarations, so make sure to indicate the need to deoptimize + * the script's arguments object. + */ + if (name == cx->names().arguments) { + funbox->setArgumentsHasLocalBinding(); + funbox->setDefinitelyNeedsArgsObj(); + } + } return true; } diff --git a/js/src/jit-test/tests/basic/bug855088.js b/js/src/jit-test/tests/basic/bug855088.js new file mode 100644 index 00000000000..9d1145616de --- /dev/null +++ b/js/src/jit-test/tests/basic/bug855088.js @@ -0,0 +1,5 @@ + +(function (y) { + arguments.y = 2; + with (0) var arguments=5; +})(1);