Repository navigation
A trait names its method as §11.4 names an extension's: Trait.method(args) (D169, #2520) - #2798
Merged
Merged
Conversation
…ethod(args) (D169, #2520) Ruled 2026-10-28 (D169) with the §11.4 words blessed verbatim, which this lands. Two traits of equal rank giving a type one method name made every choice unspellable: `Unit1.one()` "undefined variable", `f64.Unit1.one()` "unknown field", and the ambiguity error's advice left only a wrapper generic. - check_qualified_trait_call, beside check_qualified_extension_call: a qualifier that is no local, type or function and names a trait (lookup_trait_named: the visible trait by precedence, else the prelude's, so `One.one()` reaches std's) resolves the method from that trait. An instance method takes its receiver as the first argument; a static method takes Self from the call's demand (expected_expr_type at current_value_expr_root) and is refused, not guessed, with none. Sema records the function (comp_resolved) and the qualifier mark MirLower already lowers for a qualified extension call: MIR needs nothing new. - The ambiguity error spells the fix: `AVal.val(…)` or `BVal.val(…)`. - maybe_register_iter_of_self_borrow checked a method-call argument's receiver as a value before the call was checked: `sum(Unit1.one(), …)` (and `f(slug.to_slug(s))`) read the qualifier as an undefined variable. It registers only a bound local's borrow. - §13.3's `Iter.empty()`-style constructors keep their own diagnostic. Tests: behav_d169_trait_qualified_calls (instance, static, as arguments, std's One past a program trait) and err_d169_static_trait_call_needs_its_use fail on the installed compiler and pass on stage1; err_2520_ambiguous_bare_trait_method expects the spelled fix; test/spec and 650 trait, dyn, iterator, borrow and extension tests pass.
Contributor
Author
|
Seed-driven battery GREEN on the stack top ba1cf73 ( |
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.
D169 (ruled; §11.4 words blessed verbatim, landed here). Draft until the stack's battery is green.