Commit 14188ea0 authored by caitpotter88's avatar caitpotter88 Committed by Commit bot

[parser] report illegal token error in ParseMemberExpressionContinuation()

Report correct error message when a scanner error occurs while parsing a tagged
template within an expression context.

BUG=v8:4829, v8:3230
LOG=N
R=adamk@chromium.org, littledan@chromium.org

Review URL: https://codereview.chromium.org/1806063002

Cr-Commit-Position: refs/heads/master@{#34839}
parent 85ce1056
......@@ -2616,6 +2616,11 @@ ParserBase<Traits>::ParseMemberExpressionContinuation(
ParseTemplateLiteral(expression, pos, classifier, CHECK_OK);
break;
}
case Token::ILLEGAL: {
ReportUnexpectedTokenAt(scanner()->peek_location(), Token::ILLEGAL);
*ok = false;
return this->EmptyExpression();
}
default:
return expression;
}
......
......@@ -7189,6 +7189,36 @@ TEST(MiscSyntaxErrors) {
RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0);
}
TEST(EscapeSequenceErrors) {
// clang-format off
const char* context_data[][2] = {
{ "'", "'" },
{ "\"", "\"" },
{ "`", "`" },
{ "`${'", "'}`" },
{ "`${\"", "\"}`" },
{ "`${`", "`}`" },
{ "f(tag`", "`);" },
{ NULL, NULL }
};
const char* error_data[] = {
"\\uABCG",
"\\u{ZZ}",
"\\u{FFZ}",
"\\u{FFFFFFFFFF }",
"\\u{110000}",
"\\u{110000",
"\\u{FFFD }",
"\\xZF",
NULL
};
// clang-format on
RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0);
}
TEST(FunctionSentErrors) {
// clang-format off
const char* context_data[][2] = {
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function tag() {}
tag(tag`\xyy`);
# Copyright 2016 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
*%(basename)s:7: SyntaxError: Invalid or unexpected token
tag(tag`\xyy`);
^^^
SyntaxError: Invalid or unexpected token
\ No newline at end of file
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function tag() {}
`${tag`\xyy`}`;
# Copyright 2016 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
*%(basename)s:7: SyntaxError: Invalid or unexpected token
`${tag`\xyy`}`;
^^^
SyntaxError: Invalid or unexpected token
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment