Bug 765055: bind rest argument when defaults are present, r=jorendorff

This commit is contained in:
Benjamin Peterson 2012-06-21 16:53:46 -07:00
parent e2564e9daa
commit 909cd93291
2 changed files with 7 additions and 0 deletions

View File

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

View File

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