Skip to content

fix(compiler): stability-review fixes — executor convergence and soundness holes - #269

Merged
julia-script merged 4 commits into
mainfrom
julia/compiler-review-stability-0b5542
Aug 27, 2026
Merged

fix(compiler): stability-review fixes — executor convergence and soundness holes#269
julia-script merged 4 commits into
mainfrom
julia/compiler-review-stability-0b5542

Conversation

@julia-script

Copy link
Copy Markdown
Owner

Implements the compiler-review-stability-fixes OpenSpec change: the 10 confirmed findings from the compiler stability review, plus two adjacent native bugs the new tests exposed.

Executor convergence

  • MIN % -1 traps on all three executors (was: native trapped, wasm/bootstrap returned 0); checkedRemainder(MIN, -1) is None everywhere, and the native path no longer emits UB srem MIN,-1.
  • Wasm float % is exact IEEE fmod via an emitted Sterbenz-exact helper (the old x - trunc(x/y)*y expansion overflowed and rounded). Verified against 200k randomized cases.
  • Bootstrap rotate counts wrap unsigned modulo lane width (negative counts previously degenerated to a shift).

Semantic soundness

  • Effect-block typing: terminals inside unsafe {} are collected; returns join through the canonical Match.join (new SEM0163 for non-representable joins) instead of last-return-wins; generic value-parameter failures stay in the failure row.
  • effectCaptureFacts visits Enum.value(x) arguments; Ownership.scanRunEnds covers PlaceReplace/EnumValue/EffectResult/EffectBindRequirement. Both switches now carry satisfies never exhaustiveness guards so the next missing fact kind is a compile error.

Native/layout hardening

  • NativeType.lanesFor resolves EffectComposite through the registered calling shape (mirrors WasmLanes.laneKindsOf).
  • CoroutineFrame.stateLayout keys frames on the full instance key including contractRow.
  • MirVerification.effectFieldLaneCount and wasm hook release consume Layout.effectFieldLanes/lane placements instead of re-deriving the walk (this family desynced once before, commit 7a8434b).
  • Discovered by the new tests: both effect-runner lowerers now pass the layout to mirType (enum captures previously lost their representation and the runner silently failed to lower), and MirLinearization.opensRuntimeContinuation gains the missing RunEffectComposite (fixes a native "non-phi forward value reference" bitcode failure when a composite result crosses blocks).

Tests

Cross-executor corpus programs (arith-convergence-*, capture-arity composite, contract-row suspension frames), EffectBlockTyping.test.ts, a place-replace loan regression test, and a wasm parity sweep. Full suite green: typecheck, biome, 223 files / 2,266 parallel tests, full native acceptance corpus.

A subagent review pass ran over the diff; remaining nits and coverage gaps are deferred to a follow-up PR — see the "Deferred to a follow-up PR" section in openspec/changes/compiler-review-stability-fixes/design.md.

…xecutors

Converges the interpreter, wasm, and native backends on the reviewed
defects and closes the semantic-analysis soundness holes:

- Signed MIN % -1 traps on every executor (wasm emits an explicit guard,
  bootstrap trap-checks) and checkedRemainder(MIN, -1) is None everywhere;
  the native path no longer emits UB srem MIN,-1.
- Wasm float remainder is exact IEEE fmod via an emitted Sterbenz-exact
  helper, replacing the overflowing div-trunc-mul-sub expansion.
- Bootstrap rotate counts wrap unsigned modulo lane width.
- Effect-block typing collects terminals inside unsafe blocks, joins all
  returns through Match.join (new SEM0163 for non-representable joins),
  and keeps generic value-parameter failures in the failure row.
- effectCaptureFacts visits EnumValue arguments; Ownership.scanRunEnds
  covers PlaceReplace/EnumValue/EffectResult/EffectBindRequirement; both
  switches are exhaustiveness-guarded.
- NativeType.lanesFor resolves EffectComposite through the registered
  calling shape; CoroutineFrame.stateLayout keys on the full instance
  key including contractRow; MirVerification.effectFieldLaneCount and
  WasmBackend hook release consume Layout's lane helpers instead of
  re-deriving the walk.
- Discovered by the new tests: effect runners pass the layout to mirType
  so enum captures keep their representation (both runner lowerers), and
  MirLinearization.opensRuntimeContinuation gains the missing
  RunEffectComposite so post-composite locals get stack storage (fixes a
  native forward-value-reference bitcode failure).

Adds cross-executor corpus programs, effect-block typing and ownership
regression tests, and the openspec change artifacts
(compiler-review-stability-fixes). Remaining review nits are tracked for
a follow-up PR (see design.md).
…-stability-0b5542

# Conflicts:
#	packages/compiler/src/ToolchainIntegrity.generated.ts
Merges the 6 delta requirements into the main specs (integer/float scalar
remainder and rotate convergence, effect-block terminal typing and captures,
place-nested loan ends) and moves the change to the archive. Task 10.3's
dedicated hook-release test is deferred to the tracked follow-up PR.
The native backend emits LLVM frem for float remainder, which lowers to
an fmod/fmodf libcall. On Linux libm is separate from libc, so the first
corpus program exercising float % broke the CI link step (undefined
reference to fmod); macOS folds libm into libSystem, which is why local
runs passed. Pass -lm on the one native link invocation.
@julia-script
julia-script merged commit c09de08 into main Aug 27, 2026
6 checks passed
julia-script added a commit that referenced this pull request Aug 27, 2026
PR #269 changed compiler sources without regenerating
ToolchainIntegrity.generated.ts; its CI passed because a build cache miss
regenerates the file live on the runner, masking the stale commit. Any branch
that gets a compiler build cache hit — like this one — fails toolchain:check
against the committed file. Regenerated to match main's sources.
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