Skip to content

Commit 0a3e96c

Browse files
BUGFIX: The reserved symbols inside functions (this, arguments) where not declared. Therefore, generated code tried to read them as global variables.
1 parent 7494473 commit 0a3e96c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mvmCodegen.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,12 @@ void functionCodegen (Ref<AstNode> statement, CodegenState* pState)
366366
fnState.curScript = code;
367367
fnState.scopes.push_back(CodegenScope());
368368

369+
//Declare function reserver symbols.
370+
fnState.scopes.back().declare("this");
371+
fnState.scopes.back().declare("arguments");
372+
369373
for (size_t i = 0; i < params.size(); ++i)
370-
fnState.scopes.rbegin()->declare(params[i]);
374+
fnState.scopes.back().declare(params[i]);
371375

372376
codegen (fnNode->getCode(), &fnState);
373377

0 commit comments

Comments
 (0)