ReviewOS

zig-utils/zig-js

ABI: implement Bun inspector fallback for type diagnostics

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

Parent: #393 Roadmap: #134 Private ABI: #140, #163, #164

Bun’s pinned determineSpecificType implementation delegates objects whose observable constructor result is falsy to Bun__inspect. Implement the exact diagnostic-reachable inspector behavior instead of retaining the current generic [object Object] projection.

Acceptance:

  • Pin the relevant ConsoleObject.Formatter / Bun__inspect source contract and document the intentionally targeted diagnostic surface.
  • Match null-prototype objects and ordinary objects with falsy/overridden constructors, including own-key ordering and Bun’s constructor-field treatment.
  • Format nested primitives, strings, Symbols, BigInts, functions, arrays, objects, accessors, and circular references with the pinned depth/layout rules.
  • Preserve proxy/custom-inspect/getter observability exactly; no accidental extra traps or coercions.
  • Preserve UTF-16/lone-surrogate content, allocation failure atomicity, and first-wins pending exceptions.
  • Share the formatter with Bun__ErrorCode__determineSpecificType and cover it through both Home and Bun profile libraries in Debug and ReleaseSafe.
  • Add focused differential fixtures against pinned Bun where host support is available and deterministic checked-in expectations everywhere.

Backward compatibility is out of scope; implement the clean pinned behavior.

9 days ago

Completed on main in 4fd4431, 33eba7c, and 522e19c.

  • Fixed explicit-null prototype semantics so Object.create(null) reaches the pinned fallback.
  • Implemented the shared diagnostic inspector with constructor suppression, own-key order, descriptors, nested types, sparse arrays, cycles, depth 8, proxy target projection, and custom inspect/helper behavior.
  • Pinned ErrorCode.cpp, ConsoleObject.zig, and BunObject.zig at Bun 4982b91 in docs/abi/bun-diagnostic-inspector-4982b91.json.
  • Captured live Bun 1.3.14 differential cases as deterministic unit and compiled-consumer expectations.
  • Focused Debug unit coverage passes 3/3 without leaks; Home and Bun consumers pass in Debug; the focused unit and both consumers pass in ReleaseSafe; the pinned Bun source audit passes.

Sign in to comment on this issue.