[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}
This commit is contained in:
parent
8393133d6d
commit
c7c5b49298
@ -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;
|
||||
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;
|
||||
PushBack('#'); // Undo Advance()
|
||||
ReportScannerError(source_pos(), MessageTemplate::kInvalidOrUnexpectedToken);
|
||||
return Token::ILLEGAL;
|
||||
}
|
||||
|
||||
Token::Value Scanner::ScanTemplateSpan() {
|
||||
|
17
test/mjsunit/harmony/private-name-surrogate-pair.js
Normal file
17
test/mjsunit/harmony/private-name-surrogate-pair.js
Normal file
@ -0,0 +1,17 @@
|
||||
// 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);
|
Loading…
Reference in New Issue
Block a user