Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1189)

Unified Diff: src/parsing/preparser.cc

Issue 2400613003: PreParsing inner functions: Fix declaration-only variables, part 2. (Closed)
Patch Set: rebased Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/preparser.h ('k') | test/mjsunit/fixed-context-shapes-when-recompiling.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/preparser.cc
diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc
index 88470f7fa91b66374738d402ff557cb7028eae12..f7d69cf7444f585cfc14840596e145902926e32c 100644
--- a/src/parsing/preparser.cc
+++ b/src/parsing/preparser.cc
@@ -228,7 +228,7 @@ PreParserExpression PreParser::ExpressionFromIdentifier(
scope()->NewUnresolved(&factory, name.string_, start_position, end_position,
NORMAL_VARIABLE);
}
- return PreParserExpression::FromIdentifier(name);
+ return PreParserExpression::FromIdentifier(name, zone());
}
void PreParser::DeclareAndInitializeVariables(
@@ -236,20 +236,23 @@ void PreParser::DeclareAndInitializeVariables(
const DeclarationDescriptor* declaration_descriptor,
const DeclarationParsingResult::Declaration* declaration,
ZoneList<const AstRawString*>* names, bool* ok) {
- if (declaration->pattern.string_) {
+ if (declaration->pattern.identifiers_ != nullptr) {
+ DCHECK(FLAG_lazy_inner_functions);
/* Mimic what Parser does when declaring variables (see
Parser::PatternRewriter::VisitVariableProxy).
var + no initializer -> RemoveUnresolved
- let + no initializer -> RemoveUnresolved
+ let / const + no initializer -> RemoveUnresolved
var + initializer -> RemoveUnresolved followed by NewUnresolved
- let + initializer -> RemoveUnresolved
+ let / const + initializer -> RemoveUnresolved
*/
if (declaration->initializer.IsEmpty() ||
- declaration_descriptor->mode == VariableMode::LET) {
- declaration_descriptor->scope->RemoveUnresolved(
- declaration->pattern.string_);
+ (declaration_descriptor->mode == VariableMode::LET ||
+ declaration_descriptor->mode == VariableMode::CONST)) {
+ for (auto identifier : *(declaration->pattern.identifiers_)) {
+ declaration_descriptor->scope->RemoveUnresolved(identifier);
+ }
}
}
}
« no previous file with comments | « src/parsing/preparser.h ('k') | test/mjsunit/fixed-context-shapes-when-recompiling.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698