Commit 2b69a1f0 authored by Huáng Jùnliàng's avatar Huáng Jùnliàng Committed by V8 LUCI CQ

[parser] Allow escaped async in for-of

Bug: v8:11722
Change-Id: I34569071d74f0fe68b30cf3a596ea944440f1fec
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2864703Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74361}
parent 3c047b96
...@@ -5986,7 +5986,8 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement( ...@@ -5986,7 +5986,8 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement(
expression = ParseExpressionCoverGrammar(); expression = ParseExpressionCoverGrammar();
// `for (async of` is disallowed but `for (async.x of` is allowed, so // `for (async of` is disallowed but `for (async.x of` is allowed, so
// check if the token is ASYNC after parsing the expression. // check if the token is ASYNC after parsing the expression.
bool expression_is_async = scanner()->current_token() == Token::ASYNC; bool expression_is_async = scanner()->current_token() == Token::ASYNC &&
!scanner()->literal_contains_escapes();
// Initializer is reference followed by in/of. // Initializer is reference followed by in/of.
lhs_end_pos = end_position(); lhs_end_pos = end_position();
is_for_each = CheckInOrOf(&for_info.mode); is_for_each = CheckInOrOf(&for_info.mode);
......
...@@ -7157,6 +7157,16 @@ TEST(ForOfExpressionError) { ...@@ -7157,6 +7157,16 @@ TEST(ForOfExpressionError) {
RunParserSyncTest(context_data, data, kError); RunParserSyncTest(context_data, data, kError);
} }
TEST(ForOfAsync) {
const char* context_data[][2] = {{"", ""},
{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* data[] = {"for(\\u0061sync of []) {}", nullptr};
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(InvalidUnicodeEscapes) { TEST(InvalidUnicodeEscapes) {
const char* context_data[][2] = { const char* context_data[][2] = {
......
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