[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}
This commit is contained in:
parent
c6bc6d28ec
commit
b87d99495e
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user