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()