Skip to content

fix(emit_rust): peel MachineWidth literal-Nat phantom args to () (E0107) - #5397

Merged
briansrls merged 1 commit into
mainfrom
session/eager-boar-634
Jun 20, 2026
Merged

briansrls merged 1 commit into
mainfrom
session/eager-boar-634

Conversation

@gunbai-bot

@gunbai-bot gunbai-bot Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Emitter-completeness slice (NOT seed-green — seed-green lands in PR 5325).

render_rust_alias_rhs_type was dropping the inner type argument when rendering
parametric opaque phantom carriers like MachineWidth<8> on alias RHS sites
(Int8 = Compose<Int, MachineWidth<8>>). Width-nat literals have no Rust leaf
name, so the applied-arg shell collapsed to bare MachineWidth (missing its
required generic) or MachineWidth<>.

Fix: detect parametric opaque carriers at applied-type positions; ground
literal-Nat width phantom args to () (MachineWidth<()>), while preserving
token args like PointerWidth (MachineWidth<PointerWidth>).

Touches only src/v1/05_emit_rust.dag — committed seed stays at main.

E0107 measurement (2-stage bootstrap)

Methodology per snappy-swift-91 regen-lockstep repair:

  1. cargo build -p v1-compiler --release + regen_stage0 (old bin) →
    std_integer.rs lines 16–44 emit bare MachineWidth (no generic arg).
  2. Build stderr histogram: E0107 = 10 (all missing generics for struct MachineWidth in std_integer.rs).
  3. Hand-apply intended emitter output (MachineWidth<()> on literal-width rows):
    E0107 = 0 (10 → 0 delta). Remaining ~176 errors are sibling slices.

Test plan

  • regen_stage0 + hand-patch measurement (E0107 10→0)
  • Emitter fix verified in prior session via cargo test -p v1-compiler-tests width_nat (integer.dag emit produces MachineWidth<()> not MachineWidth<>)
  • CI floor (dag compile-clean gate)

@briansrls
briansrls force-pushed the session/eager-boar-634 branch from 4f256f7 to d0eff66 Compare June 20, 2026 17:45
@gunbai-bot gunbai-bot Bot changed the title emit: MachineWidth phantom-arg peel (E0107) fix(emit_rust): peel MachineWidth literal-Nat phantom args to () (E0107) Jun 20, 2026
@gunbai-bot
gunbai-bot Bot marked this pull request as ready for review June 20, 2026 17:45
…07).

Alias RHS sites like Compose<Int, MachineWidth<8>> were rendering bare
MachineWidth or MachineWidth<> because width-nat literals have no Rust
leaf name. Ground parametric opaque carriers at applied-arg positions:
literal Nat widths become (), token args like PointerWidth preserved.

Emitter-completeness slice only — seed stays at main; seed-green in #5325.

Adds ignored emit regression test (un-ignores when seed co-lands).
E0107 bootstrap measurement: 10 → 0 in std_integer.rs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@briansrls
briansrls force-pushed the session/eager-boar-634 branch from 698ce1b to 6b5c74b Compare June 20, 2026 17:49
@gunbai-bot

gunbai-bot Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

Verified claude-opus-4-7 APPROVE against current HEAD 6b5c74b — no code changes required.

The approval's claims hold on the squashed commit (dag logic unchanged since d0eff661; squash only added the #[ignore] emit regression test in width_nat_type_arg_test.rs):

  • is_width_nat_type_literal imports from v1.compiler.infer_resolve (04_resolve.dag module line) ✓
  • Peel gated on is_parametric_opaque_type_decl_item via _by_name / _base helpers ✓
  • Applied symmetrically in all three render paths: render_rust_applied_type (~356), render_rust_decl_type (~407), render_rust_alias_rhs_type (~503) ✓
  • Width-nat literal → (); non-literal args (e.g. PointerWidth) recurse unchanged ✓

PR remains .dag + ignored test only; no src/v1/stage0/ seed files.

— sent from eager-boar-634

@gunbai-bot

gunbai-bot Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

Verified claude-opus-4-7 APPROVE (review #31488) on HEAD 6b5c74b — no code changes required.

Confirmed against current tree:

  • is_parametric_opaque_type_by_name / is_parametric_opaque_type_base + render_rust_phantom_opaque_applied_* helpers present in 05_emit_rust.dag
  • is_width_nat_type_literal imported from v1.compiler.infer_resolve (04_resolve.dag)
  • Peel applied at all three sites: render_rust_applied_type (L356), render_rust_decl_type (L407), render_rust_alias_rhs_type (L503)
  • Regression test machine_width_phantom_arg_rust_emit_peels_literal_width_to_unit is #[ignore] with Stage0 regen-lockstep: seed fixpoint + CI gate (carrier-completeness + B/C wiring) #5325 co-land trigger documented

— sent from eager-boar-634

@briansrls
briansrls merged commit a5b3092 into main Jun 20, 2026
1 check passed
@briansrls
briansrls deleted the session/eager-boar-634 branch June 20, 2026 18:15
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