Commit 3170b990 authored by Shu-yu Guo's avatar Shu-yu Guo Committed by V8 LUCI CQ

Reland "[scanner] Combine surrogate pairs at start when scanning private names"

This is a reland of c7c5b492

Changes since revert:
- Save position instead of using PushBack
- Allow private-name-surrogate-pair to fail on no_i18n builds

Original change's description:
> [scanner] Combine surrogate pairs at start when scanning private names
>
> Bug: v8:12523
> Change-Id: Ic3779fe6f20965d177d99d0a570a735df72e4fde
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3366994
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Commit-Queue: Shu-yu Guo <syg@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#78493}

Bug: v8:12523
Change-Id: I8a92953549f5b38bfa004488db42bf9d835e1222
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3368361Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78513}
parent bfcb2f82
......@@ -497,15 +497,17 @@ Token::Value Scanner::ScanPrivateName() {
next().literal_chars.Start();
DCHECK_EQ(c0_, '#');
DCHECK(!IsIdentifierStart(kEndOfInput));
if (!IsIdentifierStart(Peek())) {
ReportScannerError(source_pos(),
MessageTemplate::kInvalidOrUnexpectedToken);
return Token::ILLEGAL;
int pos = source_pos();
Advance();
if (IsIdentifierStart(c0_) ||
(CombineSurrogatePair() && IsIdentifierStart(c0_))) {
AddLiteralChar('#');
Token::Value token = ScanIdentifierOrKeywordInner();
return token == Token::ILLEGAL ? Token::ILLEGAL : Token::PRIVATE_NAME;
}
AddLiteralCharAdvance();
Token::Value token = ScanIdentifierOrKeywordInner();
return token == Token::ILLEGAL ? Token::ILLEGAL : Token::PRIVATE_NAME;
ReportScannerError(pos, MessageTemplate::kInvalidOrUnexpectedToken);
return Token::ILLEGAL;
}
Token::Value Scanner::ScanTemplateSpan() {
......
// Copyright 2022 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.
class C1 {
#𖥸 = 42;
m() { return this.#𖥸; }
}
assertEquals((new C1).m(), 42);
class C2 {
#𖥸() { return 42; }
m() { return this.#𖥸(); }
}
assertEquals((new C2).m(), 42);
......@@ -449,6 +449,9 @@
# Temporal intl tests won't work in no_i18n
'temporal/function-exist': [FAIL],
# Non-BMP characters currently aren't considered identifiers in no_i18n
'harmony/private-name-surrogate-pair': [PASS,FAIL],
}], # 'no_i18n'
##############################################################################
......
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