Skip to content

MirLower decides nothing from a name's spelling (#2043); each impl has its own copy of a trait's default method bodies (#2115) - #2090

Merged
ehartford merged 2 commits into
fix-green-docs-dirtyfrom
wave-d65f
Oct 5, 2026
Merged

ehartford merged 2 commits into
fix-green-docs-dirtyfrom
wave-d65f

Conversation

@ehartford

@ehartford ehartford commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2043. Fixes #2115.

Eric Hartford added 2 commits October 4, 2026 21:10
… by Sema's MethodLowering record, a std generic is Sema's identity (#2043, D65 phase 5)

The last 178 comparisons of a name against a string literal in
src/MirLower.w are gone. Sema records, per checked method call, how it
lowers (MethodLowering: the Option/Result combinators, explicit drop,
is_empty via len, …) and which std generic a type is (StdGeneric);
MirLower switches on the records. `mirlower-no-name-dispatch`, a dep of
stage1, holds the count at 0. audit:resolution judges every method call
MIR lowered against Sema's record (88423 in the compiler, 0 without one).
…2115); every method-call node has a lowering record (#2043)

#2115: a default method's body was one set of nodes checked once per impl,
and what Sema records about a body is keyed by node, so the impl checked
last decided every impl's call targets and generic instances: A.shout()
ran B.name, and A.level() ran B.rank on an A and read past it. Before the
pool is frozen each impl of a trait gets its own copy of each default body
(AstPool.clone_default_method_bodies); Sema checks and codegen lowers the
impl's copy. A copy that may suspend says so for the trait's method. An
impl registered under an owner key (#1457) has its default bodies checked
and its dispatch entry found under that key.

#2043 follow-ups, found by MirLower refusing a method call with no record:
- every call written recv.name(..) has a record, whichever rule resolved
  it (a namespace-qualified extension call had none);
- a method of an `impl Drop for T` block is T's drop body by its impl,
  not by its name's text: std's CString.drop beside a user's CString was
  lowered as an ordinary method and dropped its own receiver (recursion);
- a written receiver type is resolved while its body is checked, not
  looked up as frozen (a FixedString[4].new() with its import missing hit
  a phase bug in place of the diagnostic).

Evidence: test/behavior/behav_default_method_per_impl.w prints
'b! b!' / 'b? b?' / '4372086800 2' on main and 'a! b!' / 'a? b?' / '1 2'
here; behav_1457_trait_impls_own_module_type, behav_extension_coherence,
behav_prelude_shadow_types (MIR: no drop(_1) in CString$m$….drop) pass.
@ehartford
ehartford changed the base branch from main to fix-green-docs-dirty October 5, 2026 04:11
@ehartford
ehartford added this pull request to stack #2114 October 5, 2026 04:11
@ehartford ehartford changed the title WIP: D65 phase 5 — MirLower name-text decisions read Sema's record (#2043) MirLower decides nothing from a name's spelling (#2043); each impl has its own copy of a trait's default method bodies (#2115) Oct 5, 2026
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN for this stack (with run tools/battery.w, pinned seed, 2026-10-04): gate rc=0 (1155s), UAT rc=0, battery-checks rc=0, on 73f0b39bf. The stack was then reordered and rebased onto main with no change to any build input (tree diff empty apart from docs); green recorded by inputs (:last-green).

@ehartford
ehartford marked this pull request as ready for review October 5, 2026 04:11
@ehartford
ehartford merged commit 32298ca into main Oct 5, 2026
@ehartford
ehartford deleted the wave-d65f branch October 5, 2026 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant