Skip to content

Fix #708, #574, #565: boxed-primitive wrapper coercion#800

Merged
nickna merged 2 commits into
mainfrom
wrk/boxed-primitives-708-batch
Jun 17, 2026
Merged

Fix #708, #574, #565: boxed-primitive wrapper coercion#800
nickna merged 2 commits into
mainfrom
wrk/boxed-primitives-708-batch

Conversation

@nickna

@nickna nickna commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Part of the Batch-1 "boxed-primitive value semantics" cluster. Ships three tightly-coupled, regression-free fixes; the two remaining Batch-1 issues (#475, #449/#474) are split off (see below).

Fixes

Verification

  • Full suite green: 13,419 / 13,419.
  • Test262 interpreted baseline: 29 new passes (committed surgically, isolated by regenerating interpreted.txt on main vs this branch — only those lines changed): JSON value/space-{number,string}-object, String fromCharCode/fromCodePoint/concat/toString/valueOf, Number valueOf, new-expression wrapper coercion (S11.2.2), and Array.prototype.*.call over a number/boolean primitive. No Pass→Fail regressions. (fromCharCode/S9.7_A3.1_T4 moves RuntimeErrorFail: an object-with-valueOf arg, still unsupported but no longer crashing.) Compiled baseline unchanged (Compiled JSON.stringify unwraps a plain object that has a __primitiveValue field (boxed-primitive check too loose) #565 has no Test262 case).

Deferred (kept open)

nickna added 2 commits June 17, 2026 10:50
#708: new Number/String/Boolean wrappers coerce to their primitive. Register
valueOf/toString on the Number and String built-ins; add an interpreter
ToPrimitive (OrdinaryToPrimitive) wired into +, arithmetic/comparison/bitwise
(via CoerceToNumber), loose ==, template literals, and String.fromCharCode/
fromCodePoint, so a wrapper reduces to its [[PrimitiveValue]] instead of
"[object Object]"/NaN, and `String.fromCharCode(new Number(1))` no longer crashes.

#574: JSON.stringify honors a user-overridden valueOf/toString on a wrapper —
Number->ToNumber, String->ToString (both through ToPrimitive), Boolean->the
[[BooleanData]] slot. JSON's value and space unwrap route through the interpreter.

#565: compiled JSON.stringify gates the boxed-primitive unwrap on a string
__primitiveType tag, matching the interpreter — a plain object that merely has
a __primitiveValue field is no longer unwrapped.

#475 (enumeration) is intentionally not included here: making Object.keys/values/
entries respect enumerability exposed two pre-existing gaps (for-in not filtering
internal slots, and Object.defineProperty resetting an existing property's
enumerable flag) that need their own fix. Tracked separately.

Full test suite green (13419).
Boxed-primitive coercion (#708) and JSON valueOf/toString dispatch (#574) flip
29 interpreted Test262 tests to Pass: JSON/stringify value/space-{number,string}-object,
String fromCharCode/fromCodePoint/concat/toString/valueOf, Number valueOf,
new-expression wrapper coercion (S11.2.2), and Array.prototype.*.call over a
number/boolean primitive. fromCharCode/S9.7_A3.1_T4 moves RuntimeError->Fail
(object-with-valueOf arg, still unsupported — no longer crashes). Isolated by
regenerating interpreted.txt on main vs this branch; only these lines changed.
Compiled baseline unchanged (#565 has no Test262 case).
@nickna nickna merged commit 8042481 into main Jun 17, 2026
3 checks 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