Change syntax error message for illegal token.
It used to say "Unexpected token ILLEGAL", now it says "Invalid or unexpected token". R=jkummerow@chromium.org BUG=chromium:257405 LOG=N Review URL: https://codereview.chromium.org/1758663002 Cr-Commit-Position: refs/heads/master@{#34431}
This commit is contained in:
parent
6eb483f878
commit
879b617b19
@ -395,6 +395,7 @@ class CallSite {
|
||||
T(InvalidLhsInPrefixOp, \
|
||||
"Invalid left-hand side expression in prefix operation") \
|
||||
T(InvalidRegExpFlags, "Invalid flags supplied to RegExp constructor '%'") \
|
||||
T(InvalidOrUnexpectedToken, "Invalid or unexpected token") \
|
||||
T(JsonParseUnexpectedEOS, "Unexpected end of JSON input") \
|
||||
T(JsonParseUnexpectedToken, "Unexpected token % in JSON at position %") \
|
||||
T(JsonParseUnexpectedTokenNumber, "Unexpected number in JSON at position %") \
|
||||
|
@ -992,27 +992,23 @@ template <class Traits>
|
||||
void ParserBase<Traits>::GetUnexpectedTokenMessage(
|
||||
Token::Value token, MessageTemplate::Template* message, const char** arg,
|
||||
MessageTemplate::Template default_) {
|
||||
*arg = nullptr;
|
||||
switch (token) {
|
||||
case Token::EOS:
|
||||
*message = MessageTemplate::kUnexpectedEOS;
|
||||
*arg = nullptr;
|
||||
break;
|
||||
case Token::SMI:
|
||||
case Token::NUMBER:
|
||||
*message = MessageTemplate::kUnexpectedTokenNumber;
|
||||
*arg = nullptr;
|
||||
break;
|
||||
case Token::STRING:
|
||||
*message = MessageTemplate::kUnexpectedTokenString;
|
||||
*arg = nullptr;
|
||||
break;
|
||||
case Token::IDENTIFIER:
|
||||
*message = MessageTemplate::kUnexpectedTokenIdentifier;
|
||||
*arg = nullptr;
|
||||
break;
|
||||
case Token::FUTURE_RESERVED_WORD:
|
||||
*message = MessageTemplate::kUnexpectedReserved;
|
||||
*arg = nullptr;
|
||||
break;
|
||||
case Token::LET:
|
||||
case Token::STATIC:
|
||||
@ -1021,17 +1017,17 @@ void ParserBase<Traits>::GetUnexpectedTokenMessage(
|
||||
*message = is_strict(language_mode())
|
||||
? MessageTemplate::kUnexpectedStrictReserved
|
||||
: MessageTemplate::kUnexpectedTokenIdentifier;
|
||||
*arg = nullptr;
|
||||
break;
|
||||
case Token::TEMPLATE_SPAN:
|
||||
case Token::TEMPLATE_TAIL:
|
||||
*message = MessageTemplate::kUnexpectedTemplateString;
|
||||
*arg = nullptr;
|
||||
break;
|
||||
case Token::ESCAPED_STRICT_RESERVED_WORD:
|
||||
case Token::ESCAPED_KEYWORD:
|
||||
*message = MessageTemplate::kInvalidEscapedReservedWord;
|
||||
*arg = nullptr;
|
||||
break;
|
||||
case Token::ILLEGAL:
|
||||
*message = MessageTemplate::kInvalidOrUnexpectedToken;
|
||||
break;
|
||||
default:
|
||||
const char* name = Token::String(token);
|
||||
|
@ -339,6 +339,11 @@ test(function() {
|
||||
eval("/a/x.test(\"a\");");
|
||||
}, "Invalid regular expression flags", SyntaxError);
|
||||
|
||||
// kInvalidOrUnexpectedToken
|
||||
test(function() {
|
||||
eval("'\n'");
|
||||
}, "Invalid or unexpected token", SyntaxError);
|
||||
|
||||
//kJsonParseUnexpectedEOS
|
||||
test(function() {
|
||||
JSON.parse("{")
|
||||
|
@ -206,14 +206,14 @@ PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescri
|
||||
PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'caller'); return descriptor.get === descriptor.set; })() is true
|
||||
PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'arguments'); return descriptor.get === descriptor.set; })() is true
|
||||
PASS 'use strict'; (function f() { for(var i in this); })(); true; is true
|
||||
PASS 'use strict'̻ threw exception SyntaxError: Unexpected token ILLEGAL.
|
||||
PASS (function(){'use strict'̻}) threw exception SyntaxError: Unexpected token ILLEGAL.
|
||||
PASS 'use strict'5.f threw exception SyntaxError: Unexpected token ILLEGAL.
|
||||
PASS (function(){'use strict'5.f}) threw exception SyntaxError: Unexpected token ILLEGAL.
|
||||
PASS 'use strict';̻ threw exception SyntaxError: Unexpected token ILLEGAL.
|
||||
PASS (function(){'use strict';̻}) threw exception SyntaxError: Unexpected token ILLEGAL.
|
||||
PASS 'use strict';5.f threw exception SyntaxError: Unexpected token ILLEGAL.
|
||||
PASS (function(){'use strict';5.f}) threw exception SyntaxError: Unexpected token ILLEGAL.
|
||||
PASS 'use strict'̻ threw exception SyntaxError: Invalid or unexpected token.
|
||||
PASS (function(){'use strict'̻}) threw exception SyntaxError: Invalid or unexpected token.
|
||||
PASS 'use strict'5.f threw exception SyntaxError: Invalid or unexpected token.
|
||||
PASS (function(){'use strict'5.f}) threw exception SyntaxError: Invalid or unexpected token.
|
||||
PASS 'use strict';̻ threw exception SyntaxError: Invalid or unexpected token.
|
||||
PASS (function(){'use strict';̻}) threw exception SyntaxError: Invalid or unexpected token.
|
||||
PASS 'use strict';5.f threw exception SyntaxError: Invalid or unexpected token.
|
||||
PASS (function(){'use strict';5.f}) threw exception SyntaxError: Invalid or unexpected token.
|
||||
PASS 'use strict';1-(eval=1); threw exception SyntaxError: Unexpected eval or arguments in strict mode.
|
||||
PASS (function(){'use strict';1-(eval=1);}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
|
||||
PASS 'use strict';arguments=1; threw exception SyntaxError: Unexpected eval or arguments in strict mode.
|
||||
|
@ -39,13 +39,13 @@ PASS function test() { return 0 } lab: 1 is 1
|
||||
PASS function test() { while(0) break lab } lab: 1 threw exception SyntaxError: Undefined label 'lab'.
|
||||
PASS function test() { while(0) continue lab } lab: 1 threw exception SyntaxError: Undefined label 'lab'.
|
||||
PASS var éĀʯΈᢨ = 101; éĀʯΈᢨ; is 101
|
||||
PASS var f÷; threw exception SyntaxError: Unexpected token ILLEGAL.
|
||||
PASS var f÷; threw exception SyntaxError: Invalid or unexpected token.
|
||||
PASS var \u0061 = 102; a is 102
|
||||
PASS var f\u0030 = 103; f0 is 103
|
||||
PASS var \u00E9\u0100\u02AF\u0388\u18A8 = 104; \u00E9\u0100\u02AF\u0388\u18A8; is 104
|
||||
PASS var f\u00F7; threw exception SyntaxError: Unexpected token ILLEGAL.
|
||||
PASS var \u0030; threw exception SyntaxError: Unexpected token ILLEGAL.
|
||||
PASS var test = { }; test.i= 0; test.i\u002b= 1; test.i; threw exception SyntaxError: Unexpected token ILLEGAL.
|
||||
PASS var f\u00F7; threw exception SyntaxError: Invalid or unexpected token.
|
||||
PASS var \u0030; threw exception SyntaxError: Invalid or unexpected token.
|
||||
PASS var test = { }; test.i= 0; test.i\u002b= 1; test.i; threw exception SyntaxError: Invalid or unexpected token.
|
||||
PASS var test = { }; test.i= 0; test.i+= 1; test.i; is 1
|
||||
PASS successfullyParsed is true
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user