Skip to content

Commit fd56f8a

Browse files
committed
OS 7249217: Rest is able to be in a slot in arguments optimization case
We hit an assert with rest in a case where we trigger an arguments scope object optimization. In the case where we don't actually need to create a scope object, rest was hard coded to not be in a slot. This was based on an assumption from a very long time ago; since then rest is no different to other formals when determining whether it is in a slot. I removed the special casing and added the test.
1 parent 4302156 commit fd56f8a

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

lib/Runtime/ByteCode/Symbol.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,7 @@ bool Symbol::IsInSlot(FuncInfo *funcInfo, bool ensureSlotAlloc)
7272
}
7373
if (funcInfo->GetHasHeapArguments() && this->GetIsFormal() && ByteCodeGenerator::NeedScopeObjectForArguments(funcInfo, funcInfo->root))
7474
{
75-
// Rest is a special case - it will be in a register.
76-
if (funcInfo->root->sxFnc.pnodeRest != this->decl)
77-
{
78-
return true;
79-
}
75+
return true;
8076
}
8177
if (this->GetIsGlobalCatch())
8278
{

test/es6/rest.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,21 @@ var tests = [
361361
}));
362362
}
363363
}
364+
},
365+
{
366+
name: "OS 7249217: Rest is able to be in a slot in arguments optimization case",
367+
body: function () {
368+
function foo(...argArr9) {
369+
var protoObj0 = {};
370+
with (protoObj0) {
371+
arguments;
372+
var f = function () { assert.areEqual([1,2,3], argArr9, "Arguments scope object optimization allows rest to function correctly inside with"); };
373+
f();
374+
}
375+
assert.areEqual([1,2,3], argArr9, "Arguments scope object optimization allows rest to function correctly");
376+
}
377+
foo(1,2,3);
378+
}
364379
}
365380
];
366381

0 commit comments

Comments
 (0)