You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Impl method arity is not checked against the trait (types are, D140): an extra parameter fails late #988
Restated 2026-10-25. An impl method's return type and parameter types are now checked against the trait (D140). What is left: arity is not. An impl method with an extra parameter is accepted at the impl, and the mismatch surfaces only at a call.
Original report
Classification
Conformance-checking gap, low severity: fail-late, never fail-silent (audit finding TRAIT-001, downgraded after verification).
Source chain
select_trait_impl (src/SemaCheck.w:16899) is name-level only: an impl block naming the trait satisfies the bound regardless of method signatures. Probe .audit/probes/readonly_pass_20260903/trait_probe.w declares impl Equal for Box2 with a wrong-arity eq2 — accepted at the impl site; the error surfaces only at a call, against the impl's own signature. Concrete-impl dispatch governs everywhere, which is also why impl Eq for str's other: &str works despite the trait's by-value Self. Companion fear disproven: by-value other: Self does NOT consume at method call sites even for Drop types (trait_probe2/3.w pass with post-call use).
Repair boundary
Emit a declaration-site diagnostic when an impl method's arity/parameter types diverge from the trait declaration; keep concrete dispatch as the call-site rule. Test matrix: arity mismatch, param-type mismatch, missing method, plus the passing by-value/drop cases as negative controls.
Review: reproduced, with one case that is worse than "fail-late"
Verdict. Established on current main. An impl Trait for Type block is accepted regardless of whether its method signatures match the trait's declarations, and regardless of whether every trait method is present. Errors, when they come, come from the call site against the impl's own signature. For a parameter-type mismatch that is a reasonable but misattributed diagnostic. For an arity mismatch it is not "fail-late" but "fail at LLVM": with check passes, the typed MIR validator passes, MIR emits a two-argument call to a three-parameter method, and the LLVM verifier aborts the build with an Incorrect number of arguments passed to called function dump and a bare error: code generation failed. A missing method is never diagnosed at all (that is #1002's territory for dyn; for static dispatch it simply compiles).
rejected: wrong argument type in call to 'Box2.eq2' at a.eq2(b)inside same, not at the impl
n/a
control: conforming impl
ok
true
Tools on the arity case: --validate-all: ok; with analyze a_arity.w audit:all: violations=2 FAILED (the analyzer's caller-marshalling audit does catch it, which is the right tool to promote into check).
Source
src/SemaCheck.w:16993select_trait_impl and :16957select_trait_impl_tiered: impl selection by (type, trait) name only.
The only trait-related diagnostics in SemaCheck.w are "does not implement trait ... required for dyn parameter" (:16284) and "... required by bound" (:16857), both keyed on the existence of an impl block, never on its contents. grep for a declaration-site signature check ("missing trait method", "trait method signature") finds nothing in src/Sema*.w.
The MIR for same in the arity case: call const fn sym747(copy _1.*, copy _2) against Box2.eq2 with locals _1, _2, _3: ty3 (three parameters).
Spec
§11.1 (line 5013) shows the impl form with the same signature as the trait, and §11.2 says instantiation-time checking reports "the concrete type, the unsupported operation, and the instantiation". Nothing in §11 states in so many words that an impl must provide every declared method with a matching signature; the language assumes it. This is a place where the spec should say the rule so the declaration-site diagnostic has a normative home (a one-sentence addition under §11.1 is enough, but only the maintainer authors it).
Related PRs
None since 450733e touch select_trait_impl. #1002 (open, same author) covers the dyn consequence of a missing method (null vtable slot); this issue is the static-dispatch and declaration-site side of the same gap.
Would I champion a fix? Yes.
Acceptance criteria:
At the impl declaration, for each trait method: report a missing method, an arity mismatch, and a parameter/return type mismatch (after substituting Self), with the diagnostic anchored on the impl method (or the impl header for a missing one) and naming the trait's expected signature.
Receiver-mode divergence (&self vs mut self vs move self) is either checked under the same rule or explicitly exempted by ruling; the report's observation that impl Eq for str uses other: &str against a by-value trait parameter suggests the stdlib itself relies on the current laxity, so the sweep must run over lib/std first.
changed the title [-]Impl method signatures are never checked against trait declarations (fail-late)[/-][+]Impl method arity is not checked against the trait (types are, D140): an extra parameter fails late[/+]on Oct 25, 2026
Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced for arity only.
$ cat arity.w
trait Equal:
fn eq2(self: &Self, other: &Self) -> bool
type Box2:
n: i32
impl Equal for Box2:
fn eq2(other: &Self, extra: i32) -> bool: true
fn main:
print("impl accepted")
$ with check arity.w
ok
# a wrong return type: error: impl method 'eq2' return type does not match trait 'Equal'
# a wrong parameter type: error: parameter `other` is `i32`; it must match the trait's `&Box2` (D140)
pre-release: a misleading late diagnostic on ordinary trait code; the fix is one count comparison beside the D140 check.
Fixed on main by 105285c (#2693), merged through stack 6 whose seed-driven battery was green on its top (gate, uat and survey all green). Regression test: test/compile_errors/err_988_impl_method_arity.w.
Activity
ehartford commentedon Sep 16, 2026
Review: reproduced, with one case that is worse than "fail-late"
Verdict. Established on current
main. Animpl Trait for Typeblock is accepted regardless of whether its method signatures match the trait's declarations, and regardless of whether every trait method is present. Errors, when they come, come from the call site against the impl's own signature. For a parameter-type mismatch that is a reasonable but misattributed diagnostic. For an arity mismatch it is not "fail-late" but "fail at LLVM":with checkpasses, the typed MIR validator passes, MIR emits a two-argument call to a three-parameter method, and the LLVM verifier aborts the build with anIncorrect number of arguments passed to called functiondump and a bareerror: code generation failed. A missing method is never diagnosed at all (that is #1002's territory fordyn; for static dispatch it simply compiles).Tested revision and compiler
main@ 5809ac1 (2026-09-14)with buildof 5809ac1 in a detached worktree, self-reportswith v0.15.2.1Probe matrix
Common prelude:
trait Equal: fn eq2(self: &Self, other: &Self) -> bool,type Box2 { n: i32 },fn same[T: Equal](a: &T, b: &T) -> bool: a.eq2(b).with checkwith runfn eq2(self: &Box2, other: &Box2, extra: i32), called viasame(&x, &y)Incorrect number of arguments passed to called function!...INVALID LLVM FUNCTION same__sema__...thenerror: code generation failed, rc 1eq2andne2, impl provides onlyeq2;same(&x, &x)true, rc 0fn eq2(self: &Box2, other: i32);same(&x, &x)wrong argument type in call to 'Box2.eq2'ata.eq2(b)insidesame, not at the impltrueTools on the arity case:
--validate-all: ok;with analyze a_arity.w audit:all:violations=2 FAILED(the analyzer's caller-marshalling audit does catch it, which is the right tool to promote intocheck).Source
src/SemaCheck.w:16993select_trait_impland:16957select_trait_impl_tiered: impl selection by (type, trait) name only.SemaCheck.ware "does not implement trait ... required for dyn parameter" (:16284) and "... required by bound" (:16857), both keyed on the existence of an impl block, never on its contents.grepfor a declaration-site signature check ("missing trait method", "trait method signature") finds nothing insrc/Sema*.w.samein the arity case:call const fn sym747(copy _1.*, copy _2)againstBox2.eq2with locals_1,_2,_3: ty3(three parameters).Spec
§11.1 (line 5013) shows the impl form with the same signature as the trait, and §11.2 says instantiation-time checking reports "the concrete type, the unsupported operation, and the instantiation". Nothing in §11 states in so many words that an impl must provide every declared method with a matching signature; the language assumes it. This is a place where the spec should say the rule so the declaration-site diagnostic has a normative home (a one-sentence addition under §11.1 is enough, but only the maintainer authors it).
Related PRs
None since 450733e touch
select_trait_impl. #1002 (open, same author) covers thedynconsequence of a missing method (null vtable slot); this issue is the static-dispatch and declaration-site side of the same gap.Would I champion a fix? Yes.
Acceptance criteria:
Self), with the diagnostic anchored on the impl method (or the impl header for a missing one) and naming the trait's expected signature.&selfvsmut selfvsmove self) is either checked under the same rule or explicitly exempted by ruling; the report's observation thatimpl Eq for strusesother: &stragainst a by-value trait parameter suggests the stdlib itself relies on the current laxity, so the sweep must run overlib/stdfirst.validate_mir_bodyrejects a call whose argument count differs from the callee's parameter count (the same typed-call validator await in fn-param defaults checks green but is invisible to the suspend artifact #986 needs).test/compile_errorsfixtures for the three mismatch kinds plus the passing by-value/Drop controls the report lists as negative cases.Untested
Trait methods with generic parameters and associated-type mismatches were not probed. Linux and Windows not executed.
[-]Impl method signatures are never checked against trait declarations (fail-late)[/-][+]Impl method arity is not checked against the trait (types are, D140): an extra parameter fails late[/+]ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced for arity only.pre-release: a misleading late diagnostic on ordinary trait code; the fix is one count comparison beside the D140 check.
Sema: an impl method takes as many parameters as its trait declares (#…
ehartford commentedon Oct 26, 2026
Fixed on main by 105285c (#2693), merged through stack 6 whose seed-driven battery was green on its top (gate, uat and survey all green). Regression test:
test/compile_errors/err_988_impl_method_arity.w.