Skip to content

test262: JSON conformance fixes (wave 15) - #78

Merged
hiett merged 1 commit into
experiment/js-frontendfrom
js262/wave15-JSON
Jul 15, 2026
Merged

test262: JSON conformance fixes (wave 15)#78
hiett merged 1 commit into
experiment/js-frontendfrom
js262/wave15-JSON

Conversation

@hiett

@hiett hiett commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Raises JSON/stringify test262 conformance.

Fixes (sec-serializejsonproperty)

  1. Wrapper-object unwrapping (step 4.a-4.c). new Number(n)/new String(s)/new Boolean(b) now serialize as their wrapped primitive rather than an empty object, including wrappers nested in an object/array or produced by a toJSON/replacer. Fixes JSON/stringify/value-boolean-object.

  2. Cyclical-structure detection (SerializeJSONObject/Array step 1). A self-referential object/array now throws a catchable TypeError instead of hanging. json_serialize_cell keeps an ancestor stack (pushed on entry, popped on exit) so a diamond (same ref in sibling positions) is still serialized. Clears all six JSON/stringify/*circular* hangs.

Impact

JSON/stringify + JSON/parse run tally: pass 65 -> 72, timeouts 6 -> 0. No new failures.

Runtime changes are confined to the JSON serializer (json_serialize_value, json_serialize_cell, json_stringify); no shared helpers touched, no new FFI exports. Spec-driven tests appended at EOF of js_compiler_test.gleam.

Two SerializeJSONProperty conformance fixes (sec-serializejsonproperty):

- Step 4.a-4.c: a Number/String/Boolean wrapper object (new Number(n),
  new String(s), new Boolean(b)) now serializes as its wrapped primitive
  instead of an empty object, so JSON.stringify(new Boolean(true)) is
  "true", including wrappers nested in an object/array or returned from a
  toJSON/replacer. Adds json_unwrap_primitive; matches test262
  JSON/stringify/value-boolean-object.

- SerializeJSONObject/SerializeJSONArray step 1: a cyclical structure now
  throws a TypeError (catchable by JS try/catch) instead of looping
  forever. json_serialize_cell keeps an ancestor stack in the process
  dictionary, pushed on entry and popped on exit, so a value that merely
  appears twice in sibling positions (a diamond) is still serialized.
  Clears the six JSON/stringify circular-reference hangs.

Adds spec-driven tests mirroring the test262 cases.
@hiett
hiett merged commit 280d83d into experiment/js-frontend Jul 15, 2026
1 check passed
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.

1 participant