Skip to content

self-host: Int.div + float-literal interpolation lexing + replay Unit normalization#437

Merged
jasisz merged 3 commits into
mainfrom
fix-self-host-parity
Jun 6, 2026
Merged

self-host: Int.div + float-literal interpolation lexing + replay Unit normalization#437
jasisz merged 3 commits into
mainfrom
fix-self-host-parity

Conversation

@jasisz
Copy link
Copy Markdown
Owner

@jasisz jasisz commented Jun 6, 2026

A VM-vs-self-host parity audit during 0.24 prep found the self-hosted interpreter lagged the other backends. This PR closes the three tractable gaps; the two larger ones (higher-order functions, multi-module type resolution) are tracked in #436.

Int.div on self-host

The interpreter's builtin registry knew Int.mod but not Int.div, so any program using the 0.24 Int.div idiom hit unknown int builtin: Int.div. Added builtinIntDiv, delegating to the real Int.div so it inherits full partiality (division by zero + overflow) and the canonical error strings.

Float literals in string interpolation

"{1.5}" lexed as TkInt then choked on the . — the interpolation lexer (tokenizeInterpDigit) always emitted an int and never checked for a decimal point. Mirrored the main-path float handling with interpolation-aware variants. (Float literals outside interpolation already worked.)

Replay Unit normalization (all rust/self-host targets)

The VM and wasm-gc replay formats serialize a Unit return as JSON null; the rust/self-host backend wrapped it as a ValUnit variant object, so a recording made by one backend spuriously failed to replay on the self-host (mismatch → panic) for any Unit-returning main. The --with-replay codegen now canonicalizes ValUnit back to null at the record/replay serialization points.

Result

  • Non-interactive example corpus, aver run vs aver run --self-host: 17/25 → 21/25 parity (remaining 4 are the multi-module/refinement cases in self-host parity: higher-order functions + multi-module type resolution #436).
  • A 0.23-recorded wumpus game session (116 effects) now replays MATCH on the self-host — matching VM and wasm-gc, so the cross-version replay safety net holds on every backend.
  • src/self_host/ regenerated via aver compile --target rust.

🤖 Generated with Claude Code

jasisz and others added 3 commits June 6, 2026 10:25
…ation

Two self-host interpreter gaps surfaced by a VM-vs-self-host corpus audit:

- Int.div was missing from the interpreter's builtin registry (callInt
  dispatch + isBuiltinCallName), so any program using the 0.24 Int.div
  idiom hit 'unknown int builtin: Int.div'. Add builtinIntDiv, delegating
  to the real Int.div so it inherits full partiality (division by zero +
  overflow) and the canonical error strings.

- Float literals inside string interpolation ('{1.5}') lexed as TkInt
  then choked on the '.' — tokenizeInterpDigit always emitted TkInt and
  never checked for a decimal point. Mirror the main-path float handling
  (tokenizeAfterInt et al.) with interpolation-aware variants.

Non-interactive example corpus VM-vs-self-host parity: 17/25 -> 21/25.
Regenerated src/self_host/ via aver compile --target rust.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The VM and wasm-gc replay formats serialize a Unit return as JSON null;
the rust/self-host backend wrapped it as a ValUnit variant object, so a
recording made by one backend spuriously failed to replay on the
self-host (output mismatch -> panic) for any Unit-returning main — i.e.
almost every program. The --with-replay codegen now canonicalizes the
ValUnit variant back to null at the record and replay serialization
points, so recordings replay cleanly across VM / wasm-gc / self-host.

A 0.23-recorded wumpus game session (116 effects) now replays MATCH on
the self-host, matching VM and wasm-gc.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The self-host regen step runs 'cargo fmt' (not --all), which doesn't
descend into the aver_self_host_cli bin's generated modules; one long
line in eval/core slipped past. Run fmt --all so 'cargo fmt --all --check'
is clean in CI.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jasisz jasisz merged commit 927820e into main Jun 6, 2026
5 checks passed
@jasisz jasisz deleted the fix-self-host-parity branch June 6, 2026 09:06
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