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

Unified Diff: src/expression-classifier.h

Issue 1371263003: Prohibit let in lexical bindings (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove messages.js test Created 5 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 | « no previous file | src/messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/expression-classifier.h
diff --git a/src/expression-classifier.h b/src/expression-classifier.h
index 0c4e5884e54b81d82ab8997bf7a53ea4fc2a0fac..bd9ba7064b62f12c10ccad3652e3d1116c4e558d 100644
--- a/src/expression-classifier.h
+++ b/src/expression-classifier.h
@@ -35,11 +35,12 @@ class ExpressionClassifier {
StrictModeFormalParametersProduction = 1 << 5,
StrongModeFormalParametersProduction = 1 << 6,
ArrowFormalParametersProduction = 1 << 7,
+ LetPatternProduction = 1 << 8,
ExpressionProductions =
(ExpressionProduction | FormalParameterInitializerProduction),
- PatternProductions =
- (BindingPatternProduction | AssignmentPatternProduction),
+ PatternProductions = (BindingPatternProduction |
+ AssignmentPatternProduction | LetPatternProduction),
FormalParametersProductions = (DistinctFormalParametersProduction |
StrictModeFormalParametersProduction |
StrongModeFormalParametersProduction),
@@ -100,6 +101,8 @@ class ExpressionClassifier {
return is_valid(StrongModeFormalParametersProduction);
}
+ bool is_valid_let_pattern() const { return is_valid(LetPatternProduction); }
+
const Error& expression_error() const { return expression_error_; }
const Error& formal_parameter_initializer_error() const {
@@ -128,6 +131,8 @@ class ExpressionClassifier {
return strong_mode_formal_parameter_error_;
}
+ const Error& let_pattern_error() const { return let_pattern_error_; }
+
bool is_simple_parameter_list() const {
return !(function_properties_ & NonSimpleParameter);
}
@@ -217,6 +222,16 @@ class ExpressionClassifier {
strong_mode_formal_parameter_error_.arg = arg;
}
+ void RecordLetPatternError(const Scanner::Location& loc,
+ MessageTemplate::Template message,
+ const char* arg = nullptr) {
+ if (!is_valid_let_pattern()) return;
+ invalid_productions_ |= LetPatternProduction;
+ let_pattern_error_.location = loc;
+ let_pattern_error_.message = message;
+ let_pattern_error_.arg = arg;
+ }
+
void Accumulate(const ExpressionClassifier& inner,
unsigned productions = StandardProductions) {
// Propagate errors from inner, but don't overwrite already recorded
@@ -277,6 +292,7 @@ class ExpressionClassifier {
Error duplicate_formal_parameter_error_;
Error strict_mode_formal_parameter_error_;
Error strong_mode_formal_parameter_error_;
+ Error let_pattern_error_;
DuplicateFinder* duplicate_finder_;
};
« no previous file with comments | « no previous file | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698