Skip to content

test(ast): skip bigint literal value#8994

Closed
hi-ogawa wants to merge 1 commit intomainfrom
test-skip-estree-bigint
Closed

test(ast): skip bigint literal value#8994
hi-ogawa wants to merge 1 commit intomainfrom
test-skip-estree-bigint

Conversation

@hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Feb 10, 2025

Acorn preserves bigint literal 123n as

{
  type: "Literal",
  value: 123n,
  bigint: "123",
  raw: "123n"
  ...
}

but this is serialized into value: "123n" in https://github.com/oxc-project/acorn-test262/blob/ccd386837e02a92036b948239c67abf864cdd785/index.mjs#L56-L60

Since OXC cannot emit non-json 123n and use null instead, this creates many diffs like:

- value: "123n"
+ value: null

For now, I stripped such diff in conformance runner.

Copy link
Contributor Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the C-test Category - Testing. Code is missing test cases, or a PR is adding them label Feb 10, 2025
@hi-ogawa hi-ogawa marked this pull request as ready for review February 10, 2025 06:16
@overlookmotel
Copy link
Member

I suggest we change Oxc's behavior so it matches what's coming out of acorn-test262, instead of skipping it in the conformance runner. Obviously, that's wrong, but anything we do will be wrong!

To create an actual BigInt, we'll need to do a "fixup pass" on JS side after JSON.parse.

We can probably make that quite swift if we also compile and send to JS a list of "paths" to where BigInts are in the AST (e.g. for const x = [123n];, path is ['body', 0, 'declarations', 0, 'init', 'elements', 0, 'value']) - so it doesn't have to visit the whole AST to replace one BigInt. But we'll need a stateful serializer on Rust side to do that.

@overlookmotel
Copy link
Member

I changed my mind. Have changed acorn-test262 to output BigInts as null to match Oxc's current behavior - #9021. This removes the need for conformance runner to skip the fields.

I prefer this method, because I'm hoping to complete the custom serializer which omits TS fields itself soon, at which point it'll replace the code for stripping out fields in conformance runner, and I didn't want all these tests to break again at that point!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-test Category - Testing. Code is missing test cases, or a PR is adding them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants