Chromium Code Reviews| Index: src/preparser.h |
| diff --git a/src/preparser.h b/src/preparser.h |
| index 1b9af9e732600c75d36b9f3e14d8919e0f3e7bae..7d9fef2a275c4d599889b475dd2bc8c777fd8c89 100644 |
| --- a/src/preparser.h |
| +++ b/src/preparser.h |
| @@ -538,6 +538,7 @@ class ParserBase : public Traits { |
| } |
| void ReportUnexpectedToken(Token::Value token); |
| + void ReportUnexpectedTokenAt(Scanner::Location location, Token::Value token); |
| // Recursive descent functions: |
| @@ -1679,9 +1680,16 @@ ParserBase<Traits>::FunctionState::~FunctionState() { |
| } |
| + |
|
arv (Not doing code reviews)
2015/03/10 17:39:55
too many new lines
arv (Not doing code reviews)
2015/03/10 17:39:55
too many new lines
caitp (gmail)
2015/03/10 17:41:55
oops, fixed
|
| template<class Traits> |
| void ParserBase<Traits>::ReportUnexpectedToken(Token::Value token) { |
| - Scanner::Location source_location = scanner()->location(); |
| + return ReportUnexpectedTokenAt(scanner_->location(), token); |
| +} |
| + |
| + |
| +template<class Traits> |
| +void ParserBase<Traits>::ReportUnexpectedTokenAt( |
| + Scanner::Location source_location, Token::Value token) { |
| // Four of the tokens are treated specially |
| switch (token) { |
| @@ -2846,6 +2854,15 @@ typename ParserBase<Traits>::ExpressionT |
| ParserBase<Traits>::ParseArrowFunctionLiteral(int start_pos, |
| ExpressionT params_ast, |
| bool* ok) { |
| + if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) { |
| + // ASI inserts `;` after arrow parameters if a line terminator is found. |
| + // `=> ...` is never a valid expression, so report as syntax error. |
| + // If next token is not `=>`, it's a syntax error anyways. |
| + ReportUnexpectedTokenAt(scanner_->peek_location(), Token::ARROW); |
| + *ok = false; |
| + return this->EmptyExpression(); |
| + } |
| + |
| Scope* scope = this->NewScope(scope_, ARROW_SCOPE); |
| typename Traits::Type::StatementList body; |
| int num_parameters = -1; |