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

[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/+/3366994Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78493}
parent 8393133d
......@@ -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;
}
AddLiteralCharAdvance();
Advance();
if (IsIdentifierStart(c0_) ||
(CombineSurrogatePair() && IsIdentifierStart(c0_))) {
AddLiteralChar('#');
Token::Value token = ScanIdentifierOrKeywordInner();
return token == Token::ILLEGAL ? Token::ILLEGAL : Token::PRIVATE_NAME;
}
PushBack('#'); // Undo Advance()
ReportScannerError(source_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);
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