Skip to content

A trait names its method as §11.4 names an extension's: Trait.method(args) (D169, #2520) - #2798

Merged
ehartford merged 1 commit into
fix-prerelease-smallfrom
d169-trait-qualified-calls
Oct 29, 2026
Merged

ehartford merged 1 commit into
fix-prerelease-smallfrom
d169-trait-qualified-calls

Conversation

@ehartford

@ehartford ehartford commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

D169 (ruled; §11.4 words blessed verbatim, landed here). Draft until the stack's battery is green.

…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.
@ehartford
ehartford added this pull request to stack #2797 October 29, 2026 00:08
@ehartford ehartford changed the title d169 trait qualified calls A trait names its method as §11.4 names an extension's: Trait.method(args) (D169, #2520) Oct 29, 2026
@ehartford

Copy link
Copy Markdown
Contributor Author

Seed-driven battery GREEN on the stack top ba1cf73 (with run tools/battery.w: gate, uat, battery-checks).

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