ReviewOS

home-lang/home

Preserve BuildMessage diagnostics for failed dynamic imports

#640
Closed chris opened this 10 days ago ·
10 days ago

Problem

The unchanged Bun corpus test js/bun/util/inspect-error.test.js currently exposes a real Home parity gap. Importing inspect-error-fixture-bad.js should reject with Bun BuildMessage diagnostics containing the duplicate declaration location and note. Home instead rejects with a plain SyntaxError containing only:

SyntaxError: Cannot declare a const variable twice: duplicateConstDecl.

This loses the structured source location, original-declaration note, and BuildMessage formatting.

Reproduction

HOME_NATIVE_VM=1 HOME_CORPUS_FULL_VM=1 ./zig-out/bin/home test packages/runtime/test/bun-corpus/js/bun/util/inspect-error.test.js

Home: 9 pass / 1 fail. Pinned Bun 4982b91: 10 pass / 0 fail.

The failure is independently reproducible in Debug and ReleaseFast. It was surfaced while validating the realm-aware Error divot work; the other 87 unchanged inspect/reportError/console tests pass when this named case is excluded.

Acceptance criteria

  • Failed dynamic module parsing rejects with the same structured BuildMessage value and notes as pinned Bun.
  • The unchanged BuildMessage snapshot passes in Debug and ReleaseFast.
  • No snapshot edits, fixture rewrites, type substitution, or weakened assertion.

Related: #66.

10 days ago

Resolved on main by 54684429c.

The concurrent transpiler could return an AST while its parser log already contained fatal binding diagnostics. It continued printing that source, so JSC reparsed it and replaced the structured Bun diagnostic with a plain SyntaxError. The worker now rejects on parser-recorded errors at the same boundary as the synchronous module loader, preserving the original BuildMessage, source location, and declaration note.

Unchanged verification:

  • Debug inspect-error.test.js: 10 pass / 0 fail / 6 snapshots.
  • ReleaseFast inspect-error.test.js: 10 pass / 0 fail / 6 snapshots.
  • Exact named BuildMessage case: 1/1 in both modes with the original inline snapshot.
  • Runtime units: 1,824 pass / 19 existing Zig skips / 0 fail.
  • Debug and ReleaseFast builds, Zig formatting, and diff checks pass.

No snapshot, fixture, assertion, timeout, or type substitution was changed.

Sign in to comment on this issue.