ReviewOS

zig-utils/zig-js

ABI: implement private ToNumber coercion

#183
Closed chris opened this 9 days ago ·
9 days ago

Parents: #163, #164 Depends on: #180

Implement the shared private full-ECMAScript ToNumber boundary.

Acceptance:

  • Export the exact Bun__JSValue__toNumber signature.
  • Preserve exact primitive conversion for undefined, null, booleans, int32/double values, and numeric/non-numeric strings.
  • Run ordinary object ToPrimitive with number hint, including Symbol.toPrimitive, valueOf, and toString ordering.
  • Throw TypeError for Symbol and BigInt inputs or primitive results.
  • Return NaN and publish conversion throws through #180 VM pending exceptions, while ordinary numeric NaN leaves no exception pending.
  • Preserve same-VM sibling values and reject foreign-VM or invalid values safely.
  • Preserve an already pending first exception rather than replacing it.
  • Cover exact signatures, primitive matrices, coercion order, thrown hooks, Symbol/BigInt, sibling/foreign ownership, and NaN/exception distinction in the compile-link-runtime fixture.
  • Update both inventories and README/API documentation without changing public/extension counts.
9 days ago

Implemented and documented on main.

Evidence:

  • implementation: 3ae44959 (feat(abi): add private ToNumber coercion)
  • published ABI/README evidence: c1293524
  • focused private runtime fixture: 48/48 symbols linked and passed
  • Home inventory: 50/432 implemented, 382 pending
  • Bun core inventory: 50/422 implemented, 372 pending
  • public/extension accounting remains 117/19
  • public C and Bun inventory audits pass with zero drift

The fixture covers primitive conversions and signed zero, ordinary NaN without pending state, same-VM sibling strings, Symbol.toPrimitive and fallback hook order, thrown hooks, Symbol/BigInt TypeError, foreign-value rejection, and first-pending-exception preservation.

Sign in to comment on this issue.