From 6547bd2493f0c349ee18e2bb723402b6e1046895 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 24 Oct 2023 12:07:14 +0200 Subject: [PATCH] deps: V8: cherry-pick ea996ad04a68 Original commit message: [import-attributes] Remove support for numeric keys During the 2023-09 TC39 meeting the proposal has been updated to remove support for bigint and float literals as import attribute keys, due to implementation difficulties in other engines and minimal added value for JS developers. GH issue: https://github.com/tc39/proposal-import-attributes/issues/145 Bug: v8:13856 Change-Id: I0ede2bb10d6ca338a4b0870a1261ccbcd088c16f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4899760 Reviewed-by: Shu-yu Guo Commit-Queue: Joyee Cheung Cr-Commit-Position: refs/heads/main@{#90318} Refs: https://github.com/v8/v8/commit/ea996ad04a684e32cd93018f0aad2f46e6b86975 PR-URL: https://github.com/nodejs/node/pull/50183 Reviewed-By: Geoffrey Booth --- common.gypi | 2 +- deps/v8/src/parsing/parser.cc | 12 ++-------- .../test/unittests/parser/parsing-unittest.cc | 22 ++----------------- 3 files changed, 5 insertions(+), 31 deletions(-) diff --git a/common.gypi b/common.gypi index dd79c43462bec9..1b7eb92b89b34b 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.18', + 'v8_embedder_string': '-node.19', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/parsing/parser.cc b/deps/v8/src/parsing/parser.cc index 336d88b2ea195b..4a3fceed6af7c6 100644 --- a/deps/v8/src/parsing/parser.cc +++ b/deps/v8/src/parsing/parser.cc @@ -1372,16 +1372,8 @@ ImportAssertions* Parser::ParseImportAssertClause() { Expect(Token::LBRACE); while (peek() != Token::RBRACE) { - const AstRawString* attribute_key = nullptr; - if (Check(Token::STRING) || Check(Token::SMI)) { - attribute_key = GetSymbol(); - } else if (Check(Token::NUMBER)) { - attribute_key = GetNumberAsSymbol(); - } else if (Check(Token::BIGINT)) { - attribute_key = GetBigIntAsSymbol(); - } else { - attribute_key = ParsePropertyName(); - } + const AstRawString* attribute_key = + Check(Token::STRING) ? GetSymbol() : ParsePropertyName(); Scanner::Location location = scanner()->location(); diff --git a/deps/v8/test/unittests/parser/parsing-unittest.cc b/deps/v8/test/unittests/parser/parsing-unittest.cc index 24e178e2ca5eb6..add2d791c6177f 100644 --- a/deps/v8/test/unittests/parser/parsing-unittest.cc +++ b/deps/v8/test/unittests/parser/parsing-unittest.cc @@ -4877,10 +4877,7 @@ TEST_F(ParsingTest, BasicImportAssertionParsing) { "import { a as b } from 'm.js' assert { c:\n 'd'};", "import { a as b } from 'm.js' assert { c:'d'\n};", - "import { a as b } from 'm.js' assert { 0: 'b', };", - "import { a as b } from 'm.js' assert { 0n: 'b', };", "import { a as b } from 'm.js' assert { '0': 'b', };", - "import { a as b } from 'm.js' assert { 0.0: 'b', };", }; // clang-format on @@ -4942,19 +4939,13 @@ TEST_F(ParsingTest, ImportAssertionParsingErrors) { "import { a } from 'm.js'\n assert { };", "export * from 'm.js'\n assert { };", - "import { a } from 'm.js' assert { 1: 2 };", + "import { a } from 'm.js' assert { x: 2 };", "import { a } from 'm.js' assert { b: c };", "import { a } from 'm.js' assert { 'b': c };", "import { a } from 'm.js' assert { , b: c };", "import { a } from 'm.js' assert { a: 'b', a: 'c' };", "import { a } from 'm.js' assert { a: 'b', 'a': 'c' };", - "import { a } from 'm.js' assert { 0: 'b', '0': 'c' };", - "import { a } from 'm.js' assert { 0n: 'b', '0': 'c' };", - "import { a } from 'm.js' assert { 0: 'b', 0n: 'c' };", - "import { a } from 'm.js' assert { 0: 'b', 0.0: 'c' };", - "import { a } from 'm.js' assert { '0': 'b', 0n: 'c' };", - "import 'm.js' with { a: 'b' };" }; // clang-format on @@ -5008,10 +4999,7 @@ TEST_F(ParsingTest, BasicImportAttributesParsing) { "import { a as b } from 'm.js' with { c:\n 'd'};", "import { a as b } from 'm.js' with { c:'d'\n};", - "import { a as b } from 'm.js' with { 0: 'b', };", - "import { a as b } from 'm.js' with { 0n: 'b', };", "import { a as b } from 'm.js' with { '0': 'b', };", - "import { a as b } from 'm.js' with { 0.0: 'b', };", "import 'm.js'\n with { };", "import 'm.js' \nwith { };", @@ -5073,19 +5061,13 @@ TEST_F(ParsingTest, ImportAttributesParsingErrors) { "export { a } with { };", "export * with { };", - "import { a } from 'm.js' with { 1: 2 };", + "import { a } from 'm.js' with { x: 2 };", "import { a } from 'm.js' with { b: c };", "import { a } from 'm.js' with { 'b': c };", "import { a } from 'm.js' with { , b: c };", "import { a } from 'm.js' with { a: 'b', a: 'c' };", "import { a } from 'm.js' with { a: 'b', 'a': 'c' };", - "import { a } from 'm.js' with { 0: 'b', '0': 'c' };", - "import { a } from 'm.js' with { 0n: 'b', '0': 'c' };", - "import { a } from 'm.js' with { 0: 'b', 0n: 'c' };", - "import { a } from 'm.js' with { 0: 'b', 0.0: 'c' };", - "import { a } from 'm.js' with { '0': 'b', 0n: 'c' };", - "import 'm.js' assert { a: 'b' };" }; // clang-format on