Skip to content

[parser] Support BigIntLiteral in visitMemberKey - #560

Open
CSharperMantle wants to merge 1 commit into
googleprojectzero:mainfrom
CSharperMantle:fix-parserjs-bigintlit-key
Open

CSharperMantle wants to merge 1 commit into
googleprojectzero:mainfrom
CSharperMantle:fix-parserjs-bigintlit-key

Conversation

@CSharperMantle

Copy link
Copy Markdown
Contributor

Currently, when trying to parse the following program using parser.js:

({1n: 0});
class C { 1n(){} }
for (const {1n: x} of [{}]) {}

... this exception is thrown:

$ node parser.js ../../Protobuf/ast.proto /tmp/demo.js /dev/null

/home/csmantle/workspace/fuzzilli/Sources/Fuzzilli/Compiler/Parser/parser.js:263
                throw "Unknown member key type: " + member.key.type + " in declaration";
                ^
Unknown member key type: BigIntLiteral in declaration
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js v26.8.2

Similar BigInt-keyed patterns are also found in SpiderMonkey's js/src/jit-test/tests/1659595.js.

visitExpression in parser.js already handles the BigIntLiteral type; thus, fix up the visitMemberKey handling similarly.

case 'BigIntLiteral': {
return makeExpression('BigIntLiteral', { value: node.value });
}

This fix would enable correct parsing of all three patterns mentioned above.

CSharperMantle added a commit to CSharperMantle/googleprojectzero-fuzzilli that referenced this pull request Sep 15, 2026
This enables parsing of BigIntLiteral-keyed properties, methods, and
destructuring bindings, for example:

        ({1n: 0});
        class C { 1n(){} }
        for (const {1n: x} of [{}]) {}

Link: googleprojectzero#560
} else if (member.key.type === 'StringLiteral') {
body.name = member.key.value;
} else if (member.key.type === 'BigIntLiteral') {
body.name = member.key.value;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a nice and trivial fix, could you be so kind and maybe add a small test case (or extend an existing one) to CompilerTests that covers this branch and ensures the "roundtrip" works correctly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'll look into it tomorrow morning local time :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Liedtke: Done.

@CSharperMantle
CSharperMantle force-pushed the fix-parserjs-bigintlit-key branch from fd2cce4 to 1cc4f6c Compare September 16, 2026 02:15
This enables parsing of BigIntLiteral-keyed properties, methods, and
destructuring bindings, for example:

        ({1n: 0});
        class C { 1n(){} }
        for (const {1n: x} of [{}]) {}
@CSharperMantle
CSharperMantle force-pushed the fix-parserjs-bigintlit-key branch from 1cc4f6c to 91cd655 Compare September 16, 2026 02:19
CSharperMantle added a commit to CSharperMantle/googleprojectzero-fuzzilli that referenced this pull request Sep 16, 2026
This enables parsing of BigIntLiteral-keyed properties, methods, and
destructuring bindings, for example:

        ({1n: 0});
        class C { 1n(){} }
        for (const {1n: x} of [{}]) {}

Link: googleprojectzero#560
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants