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

Unified Diff: src/parser.cc

Issue 5044003: Fix bug in parser that allows "(foo):42" as a labeled statement. (Closed)
Patch Set: Created 10 years, 1 month 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 | test/mjsunit/regress/regress-918.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index a0f3b7147f20eda1457d4f41276c550d70b2b612..515eff3fb5428ff53ab0012fa51e38f379b4c109 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1692,11 +1692,13 @@ Statement* Parser::ParseExpressionOrLabelledStatement(ZoneStringList* labels,
// ExpressionStatement | LabelledStatement ::
// Expression ';'
// Identifier ':' Statement
-
+ bool starts_with_idenfifier = (peek() == Token::IDENTIFIER);
Expression* expr = ParseExpression(true, CHECK_OK);
- if (peek() == Token::COLON && expr &&
+ if (peek() == Token::COLON && starts_with_idenfifier && expr &&
expr->AsVariableProxy() != NULL &&
!expr->AsVariableProxy()->is_this()) {
+ // Expression is a single identifier, and not, e.g., a parenthesized
+ // identifier.
VariableProxy* var = expr->AsVariableProxy();
Handle<String> label = var->name();
// TODO(1240780): We don't check for redeclaration of labels
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-918.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698