Skip to content

Sema: an impl method takes as many parameters as its trait declares (#988) - #2693

Merged
ehartford merged 1 commit into
fix-987from
fix-988
Oct 26, 2026
Merged

ehartford merged 1 commit into
fix-987from
fix-988

Conversation

@ehartford

@ehartford ehartford commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Root cause: check_trait_impl_method_signature_contract (src/SemaCheck.w)
compared an impl method's return type with the trait's and D140 typed each
parameter from the trait's by name or position, but nothing compared the
counts: fn eq2(other: &Self, extra: i32) under
trait Equal: fn eq2(self: &Self, other: &Self) was accepted at the impl
and refused only at a call.

The counts of non-receiver parameters (self is D7's on both sides) must
agree: "impl method eq2 takes 2 parameter(s), and trait Equal declares 1
(D140)".

Test: test/compile_errors/err_988_impl_method_arity.w (the installed
compiler checks it clean).

Closes #988

@ehartford
ehartford added this pull request to stack #2698 October 25, 2026 23:42
@ehartford ehartford changed the title fix 988 Sema: an impl method takes as many parameters as its trait declares (#988) Oct 25, 2026
…988)

Root cause: check_trait_impl_method_signature_contract (src/SemaCheck.w)
compared an impl method's return type with the trait's and D140 typed each
parameter from the trait's by name or position, but nothing compared the
counts: `fn eq2(other: &Self, extra: i32)` under
`trait Equal: fn eq2(self: &Self, other: &Self)` was accepted at the impl
and refused only at a call.

The counts of non-receiver parameters (`self` is D7's on both sides) must
agree: "impl method `eq2` takes 2 parameter(s), and trait `Equal` declares 1
(D140)".

Test: test/compile_errors/err_988_impl_method_arity.w (the installed
compiler checks it clean).
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.

Impl method arity is not checked against the trait (types are, D140): an extra parameter fails late

1 participant