Skip to content

Commit adfcd5b

Browse files
committed
Ensure scope slot is allocated for arguments symbol when captured by lambda
When a lambda captures arguments symbol, the symbol gets the scope slots allocated while it is emitted in the lambda function. But there can be a case where the function gets reparsed and the lambda does not get emitted again. So if the function has arguments then make sure scope slot is allocated each time.
1 parent 507e4cb commit adfcd5b

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

lib/Runtime/ByteCode/ByteCodeEmitter.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4097,15 +4097,14 @@ void ByteCodeGenerator::StartEmitFunction(ParseNode *pnodeFnc)
40974097
MapFormals(pnodeFnc, ensureScopeSlot);
40984098
MapFormalsFromPattern(pnodeFnc, ensureScopeSlot);
40994099

4100-
if (!paramScope->GetCanMergeWithBodyScope())
4100+
if (funcInfo->GetHasArguments())
41014101
{
41024102
sym = funcInfo->GetArgumentsSymbol();
4103-
if (sym && funcInfo->GetHasArguments())
4104-
{
4105-
// There is no eval so the arguments may be captured in a lambda. In split scope case
4106-
// we have to make sure the param arguments is also put in a slot.
4107-
sym->EnsureScopeSlot(funcInfo);
4108-
}
4103+
Assert(sym);
4104+
4105+
// There is no eval so the arguments may be captured in a lambda.
4106+
// But we cannot relay on slots getting allocated while the lambda is emitted as the function body may be reparsed.
4107+
sym->EnsureScopeSlot(funcInfo);
41094108
}
41104109

41114110
if (pnodeFnc->sxFnc.pnodeBody)

0 commit comments

Comments
 (0)