Commit b87d9949 authored by neis's avatar neis Committed by Commit bot

[parsing] Make maybe-assigned more precise for sloppy block functions.

A script like "{ function foo() {} }" declares a VAR-variable at the
top-level and a LET-variable inside the block.  The LET-variable does
not need to be unconditionally marked as assigned.

BUG=v8:5636

Review-Url: https://codereview.chromium.org/2680443002
Cr-Commit-Position: refs/heads/master@{#42980}
parent c6bc6d28
......@@ -1487,8 +1487,7 @@ Statement* Parser::DeclareFunction(const AstRawString* variable_name,
VariableProxy* proxy =
factory()->NewVariableProxy(variable_name, NORMAL_VARIABLE);
DeclarationScope* target_scope = GetDeclarationScope();
MarkTopLevelVariableAsAssigned(target_scope, proxy);
MarkTopLevelVariableAsAssigned(scope(), proxy);
Declaration* declaration =
factory()->NewFunctionDeclaration(proxy, function, scope(), pos);
......@@ -1498,7 +1497,8 @@ Statement* Parser::DeclareFunction(const AstRawString* variable_name,
if (is_sloppy_block_function) {
SloppyBlockFunctionStatement* statement =
factory()->NewSloppyBlockFunctionStatement();
target_scope->DeclareSloppyBlockFunction(variable_name, scope(), statement);
GetDeclarationScope()->DeclareSloppyBlockFunction(variable_name, scope(),
statement);
return statement;
}
return factory()->NewEmptyStatement(kNoSourcePosition);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment