Repository navigation
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
Conversation
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.
Contributor
Author
|
Battery GREEN for this stack ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2043. Fixes #2115.
src/MirLower.wis gone. Sema records how each method call lowers (MethodLowering) and which std generic a type is; MirLower reads the record and refuses a method call that has none.mirlower-no-name-dispatchholds the count at 0.A.shout()calls B'sname#2115: a trait's default method body was one set of nodes shared by every impl, and Sema's per-node facts were those of the impl checked last:A.shout()ranB.name, andA.level()ranB.rankon anAand read past it. Each impl now has its own copy of each default body. Test:test/behavior/behav_default_method_per_impl.w(printsb! b!/4372086800 2on the previous main).