From 91cd655cfcde5496f82a9634368ebb67ffd5a023 Mon Sep 17 00:00:00 2001 From: Rong Bao Date: Tue, 15 Sep 2026 18:32:33 +0800 Subject: [PATCH] [parser] Support BigIntLiteral in visitMemberKey This enables parsing of BigIntLiteral-keyed properties, methods, and destructuring bindings, for example: ({1n: 0}); class C { 1n(){} } for (const {1n: x} of [{}]) {} --- Sources/Fuzzilli/Compiler/Parser/parser.js | 2 ++ .../CompilerTests/bigint_literal_prop_keys.js | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 Tests/FuzzilliTests/CompilerTests/bigint_literal_prop_keys.js diff --git a/Sources/Fuzzilli/Compiler/Parser/parser.js b/Sources/Fuzzilli/Compiler/Parser/parser.js index 5a447d0ad..ff5dc63e9 100644 --- a/Sources/Fuzzilli/Compiler/Parser/parser.js +++ b/Sources/Fuzzilli/Compiler/Parser/parser.js @@ -256,6 +256,8 @@ function parse(script, proto) { body.index = member.key.value; } else if (member.key.type === 'StringLiteral') { body.name = member.key.value; + } else if (member.key.type === 'BigIntLiteral') { + body.name = member.key.value; } else if (member.key.type === 'PrivateName') { assert(member.key.id.type === 'Identifier', "Expected private name ID to be an Identifier"); body.privateName = member.key.id.name; diff --git a/Tests/FuzzilliTests/CompilerTests/bigint_literal_prop_keys.js b/Tests/FuzzilliTests/CompilerTests/bigint_literal_prop_keys.js new file mode 100644 index 000000000..731ca4d98 --- /dev/null +++ b/Tests/FuzzilliTests/CompilerTests/bigint_literal_prop_keys.js @@ -0,0 +1,33 @@ +if (typeof output === "undefined") output = console.log; + +const obj1 = { 42n: 42 }; +output(obj1[42n]); +output(obj1["42"]); +output(Object.keys(obj1).length); + +const obj2 = { 1: 1, 1n: 2n, "1": "3" }; +output(Object.keys(obj2).length); +output(obj2[1n]); + +const obj3 = { + get 3n() { + return 3; + }, + set 3n(v) {}, +}; +obj3[3n] = 42; +output(obj3[3n]); + +class C { + static 2n() { + return 2; + } + 1n() { + return 1; + } +} +output(C[2n]()); +output(new C()[1n]()); + +let { 1n: x } = { 1n: "big" }; +output(x);