Commit 63f311ad authored by neis's avatar neis Committed by Commit bot

[ast] Never declare non-lexical variables as kNeedsInitialization.

R=adamk@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2232343002
Cr-Commit-Position: refs/heads/master@{#38589}
parent ec9465eb
......@@ -1249,9 +1249,9 @@ Variable* Scope::NonLocal(const AstRawString* name, VariableMode mode) {
Variable* var = map->Lookup(name);
if (var == NULL) {
// Declare a new non-local.
InitializationFlag init_flag = (mode == VAR)
? kCreatedInitialized : kNeedsInitialization;
var = map->Declare(zone(), NULL, name, mode, Variable::NORMAL, init_flag);
DCHECK(!IsLexicalVariableMode(mode));
var = map->Declare(zone(), NULL, name, mode, Variable::NORMAL,
kCreatedInitialized);
// Allocate it by giving it a dynamic lookup.
var->AllocateTo(VariableLocation::LOOKUP, -1);
}
......
......@@ -73,6 +73,8 @@ class Variable: public ZoneObject {
bool is_dynamic() const { return IsDynamicVariableMode(mode_); }
bool is_const_mode() const { return IsImmutableVariableMode(mode_); }
bool binding_needs_init() const {
DCHECK(initialization_flag_ != kNeedsInitialization ||
IsLexicalVariableMode(mode_));
return initialization_flag_ == kNeedsInitialization;
}
......
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