Commit 503ad143 authored by neis's avatar neis Committed by Commit bot

[ast] Mark temporaries as maybe-assigned by default.

This is in order to prevent accidental bugs in desugarings.

R=adamk@chromium.org
BUG=v8:5636

Review-Url: https://codereview.chromium.org/2693313002
Cr-Commit-Position: refs/heads/master@{#43237}
parent 754bb9f9
...@@ -708,7 +708,8 @@ Variable* DeclarationScope::DeclareGeneratorObjectVar( ...@@ -708,7 +708,8 @@ Variable* DeclarationScope::DeclareGeneratorObjectVar(
DCHECK(is_function_scope() || is_module_scope()); DCHECK(is_function_scope() || is_module_scope());
DCHECK_NULL(generator_object_var()); DCHECK_NULL(generator_object_var());
Variable* result = EnsureRareData()->generator_object = NewTemporary(name); Variable* result = EnsureRareData()->generator_object =
NewTemporary(name, kNotAssigned);
result->set_is_used(); result->set_is_used();
return result; return result;
} }
...@@ -1205,10 +1206,16 @@ bool Scope::RemoveUnresolved(VariableProxy* var) { ...@@ -1205,10 +1206,16 @@ bool Scope::RemoveUnresolved(VariableProxy* var) {
} }
Variable* Scope::NewTemporary(const AstRawString* name) { Variable* Scope::NewTemporary(const AstRawString* name) {
return NewTemporary(name, kMaybeAssigned);
}
Variable* Scope::NewTemporary(const AstRawString* name,
MaybeAssignedFlag maybe_assigned) {
DeclarationScope* scope = GetClosureScope(); DeclarationScope* scope = GetClosureScope();
Variable* var = new (zone()) Variable* var = new (zone())
Variable(scope, name, TEMPORARY, NORMAL_VARIABLE, kCreatedInitialized); Variable(scope, name, TEMPORARY, NORMAL_VARIABLE, kCreatedInitialized);
scope->AddLocal(var); scope->AddLocal(var);
if (maybe_assigned == kMaybeAssigned) var->set_maybe_assigned();
return var; return var;
} }
......
...@@ -483,6 +483,8 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { ...@@ -483,6 +483,8 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
// should also be invoked after resolution. // should also be invoked after resolution.
bool NeedsScopeInfo() const; bool NeedsScopeInfo() const;
Variable* NewTemporary(const AstRawString* name,
MaybeAssignedFlag maybe_assigned);
Zone* zone_; Zone* zone_;
// Scope tree. // Scope tree.
......
...@@ -3005,7 +3005,7 @@ Block* Parser::BuildRejectPromiseOnException(Block* inner_block) { ...@@ -3005,7 +3005,7 @@ Block* Parser::BuildRejectPromiseOnException(Block* inner_block) {
Context::ASYNC_FUNCTION_PROMISE_CREATE_INDEX, Context::ASYNC_FUNCTION_PROMISE_CREATE_INDEX,
new (zone()) ZoneList<Expression*>(0, zone()), kNoSourcePosition); new (zone()) ZoneList<Expression*>(0, zone()), kNoSourcePosition);
Assignment* assign_promise = factory()->NewAssignment( Assignment* assign_promise = factory()->NewAssignment(
Token::INIT, factory()->NewVariableProxy(PromiseVariable()), Token::ASSIGN, factory()->NewVariableProxy(PromiseVariable()),
create_promise, kNoSourcePosition); create_promise, kNoSourcePosition);
set_promise = set_promise =
factory()->NewExpressionStatement(assign_promise, kNoSourcePosition); factory()->NewExpressionStatement(assign_promise, 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