From 909cd93291b822a894c47824aa416a51aaa13791 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 21 Jun 2012 16:53:46 -0700 Subject: [PATCH] Bug 765055: bind rest argument when defaults are present, r=jorendorff --- js/src/frontend/BytecodeEmitter.cpp | 2 ++ js/src/jit-test/tests/arguments/defaults-with-rest.js | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index b756a2f7eea..56b20710b5d 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -5921,6 +5921,8 @@ frontend::EmitTree(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn) CheckTypeSet(cx, bce, JSOP_REST); if (Emit1(cx, bce, JSOP_UNDEFINED) < 0) return false; + if (!BindNameToSlot(cx, bce, rest)) + return JS_FALSE; if (!EmitVarOp(cx, rest, JSOP_SETARG, bce)) return false; if (Emit1(cx, bce, JSOP_POP) < 0) diff --git a/js/src/jit-test/tests/arguments/defaults-with-rest.js b/js/src/jit-test/tests/arguments/defaults-with-rest.js index 492918e39f5..adc5d7e54bb 100644 --- a/js/src/jit-test/tests/arguments/defaults-with-rest.js +++ b/js/src/jit-test/tests/arguments/defaults-with-rest.js @@ -17,3 +17,8 @@ function f3(a=rest, ...rest) { assertEqArray(rest, [2, 3, 4]); } f3(1, 2, 3, 4); +function f4(a=42, ...f) { + assertEq(typeof f, "function"); + function f() {} +} +f4()