Skip to content

Commit ea996ad

Browse files
nicolo-ribaudoV8 LUCI CQ
authored andcommitted
[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: tc39/proposal-import-attributes#145 Bug: v8:13856 Change-Id: I0ede2bb10d6ca338a4b0870a1261ccbcd088c16f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4899760 Reviewed-by: Shu-yu Guo <[email protected]> Commit-Queue: Joyee Cheung <[email protected]> Cr-Commit-Position: refs/heads/main@{#90318}
1 parent efba717 commit ea996ad

File tree

2 files changed

+4
-30
lines changed

2 files changed

+4
-30
lines changed

src/parsing/parser.cc

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,16 +1407,8 @@ ImportAssertions* Parser::ParseImportAssertClause() {
14071407
Expect(Token::LBRACE);
14081408

14091409
while (peek() != Token::RBRACE) {
1410-
const AstRawString* attribute_key = nullptr;
1411-
if (Check(Token::STRING) || Check(Token::SMI)) {
1412-
attribute_key = GetSymbol();
1413-
} else if (Check(Token::NUMBER)) {
1414-
attribute_key = GetNumberAsSymbol();
1415-
} else if (Check(Token::BIGINT)) {
1416-
attribute_key = GetBigIntAsSymbol();
1417-
} else {
1418-
attribute_key = ParsePropertyName();
1419-
}
1410+
const AstRawString* attribute_key =
1411+
Check(Token::STRING) ? GetSymbol() : ParsePropertyName();
14201412

14211413
Scanner::Location location = scanner()->location();
14221414

test/unittests/parser/parsing-unittest.cc

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4877,10 +4877,7 @@ TEST_F(ParsingTest, BasicImportAssertionParsing) {
48774877
"import { a as b } from 'm.js' assert { c:\n 'd'};",
48784878
"import { a as b } from 'm.js' assert { c:'d'\n};",
48794879

4880-
"import { a as b } from 'm.js' assert { 0: 'b', };",
4881-
"import { a as b } from 'm.js' assert { 0n: 'b', };",
48824880
"import { a as b } from 'm.js' assert { '0': 'b', };",
4883-
"import { a as b } from 'm.js' assert { 0.0: 'b', };",
48844881
};
48854882
// clang-format on
48864883

@@ -4942,19 +4939,13 @@ TEST_F(ParsingTest, ImportAssertionParsingErrors) {
49424939
"import { a } from 'm.js'\n assert { };",
49434940
"export * from 'm.js'\n assert { };",
49444941

4945-
"import { a } from 'm.js' assert { 1: 2 };",
4942+
"import { a } from 'm.js' assert { x: 2 };",
49464943
"import { a } from 'm.js' assert { b: c };",
49474944
"import { a } from 'm.js' assert { 'b': c };",
49484945
"import { a } from 'm.js' assert { , b: c };",
49494946
"import { a } from 'm.js' assert { a: 'b', a: 'c' };",
49504947
"import { a } from 'm.js' assert { a: 'b', 'a': 'c' };",
49514948

4952-
"import { a } from 'm.js' assert { 0: 'b', '0': 'c' };",
4953-
"import { a } from 'm.js' assert { 0n: 'b', '0': 'c' };",
4954-
"import { a } from 'm.js' assert { 0: 'b', 0n: 'c' };",
4955-
"import { a } from 'm.js' assert { 0: 'b', 0.0: 'c' };",
4956-
"import { a } from 'm.js' assert { '0': 'b', 0n: 'c' };",
4957-
49584949
"import 'm.js' with { a: 'b' };"
49594950
};
49604951
// clang-format on
@@ -5008,10 +4999,7 @@ TEST_F(ParsingTest, BasicImportAttributesParsing) {
50084999
"import { a as b } from 'm.js' with { c:\n 'd'};",
50095000
"import { a as b } from 'm.js' with { c:'d'\n};",
50105001

5011-
"import { a as b } from 'm.js' with { 0: 'b', };",
5012-
"import { a as b } from 'm.js' with { 0n: 'b', };",
50135002
"import { a as b } from 'm.js' with { '0': 'b', };",
5014-
"import { a as b } from 'm.js' with { 0.0: 'b', };",
50155003

50165004
"import 'm.js'\n with { };",
50175005
"import 'm.js' \nwith { };",
@@ -5073,19 +5061,13 @@ TEST_F(ParsingTest, ImportAttributesParsingErrors) {
50735061
"export { a } with { };",
50745062
"export * with { };",
50755063

5076-
"import { a } from 'm.js' with { 1: 2 };",
5064+
"import { a } from 'm.js' with { x: 2 };",
50775065
"import { a } from 'm.js' with { b: c };",
50785066
"import { a } from 'm.js' with { 'b': c };",
50795067
"import { a } from 'm.js' with { , b: c };",
50805068
"import { a } from 'm.js' with { a: 'b', a: 'c' };",
50815069
"import { a } from 'm.js' with { a: 'b', 'a': 'c' };",
50825070

5083-
"import { a } from 'm.js' with { 0: 'b', '0': 'c' };",
5084-
"import { a } from 'm.js' with { 0n: 'b', '0': 'c' };",
5085-
"import { a } from 'm.js' with { 0: 'b', 0n: 'c' };",
5086-
"import { a } from 'm.js' with { 0: 'b', 0.0: 'c' };",
5087-
"import { a } from 'm.js' with { '0': 'b', 0n: 'c' };",
5088-
50895071
"import 'm.js' assert { a: 'b' };"
50905072
};
50915073
// clang-format on

0 commit comments

Comments
 (0)