Index: src/parsing/preparser.cc |
diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc |
index 306fb264d1c17116d189d87aefedbcc65a6a8dbf..d53551430a2391936fa800debae6aa4c7f435b98 100644 |
--- a/src/parsing/preparser.cc |
+++ b/src/parsing/preparser.cc |
@@ -296,7 +296,10 @@ void PreParser::DeclareAndInitializeVariables( |
var + initializer -> RemoveUnresolved followed by NewUnresolved |
let / const + initializer -> RemoveUnresolved |
*/ |
- |
+ Scope* scope = declaration_descriptor->hoist_scope; |
+ if (scope == nullptr) { |
+ scope = this->scope(); |
+ } |
if (declaration->initializer.IsEmpty() || |
(declaration_descriptor->mode == VariableMode::LET || |
declaration_descriptor->mode == VariableMode::CONST)) { |
@@ -304,6 +307,9 @@ void PreParser::DeclareAndInitializeVariables( |
declaration_descriptor->scope->RemoveUnresolved(identifier); |
} |
} |
+ for (auto identifier : *(declaration->pattern.identifiers_)) { |
+ scope->DeclareVariableName(identifier, declaration_descriptor->mode); |
+ } |
} |
} |