Skip to content

Sema: an impl defines every method its trait declares without a default body (#1002) - #2684

Merged
ehartford merged 1 commit into
fix-1005from
fix-1002
Oct 25, 2026
Merged

ehartford merged 1 commit into
fix-1005from
fix-1002

Conversation

@ehartford

@ehartford ehartford commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Root cause: the trait-impl registration (src/SemaDecl.w, where
register_trait_default_method_for_impl runs) checked the methods an impl
writes against the trait (D140) but never that the impl writes each one the
trait leaves without a default. An impl of T omitting n was accepted;
the dyn vtable builder (CodegenTraits.w) then filled the slot with null, and
x.n() through &dyn T trapped at run time (rc=133) with no message.

check_trait_impl_complete refuses it at the impl: "impl of T for A does
not define n, which the trait declares with no default body".

Test: test/compile_errors/err_1002_impl_missing_trait_method.w. The
installed compiler checks it clean.

Closes #1002

@ehartford
ehartford added this pull request to stack #2689 October 25, 2026 23:07
@ehartford ehartford changed the title fix 1002 Sema: an impl defines every method its trait declares without a default body (#1002) Oct 25, 2026
…lt body (#1002)

Root cause: the trait-impl registration (src/SemaDecl.w, where
register_trait_default_method_for_impl runs) checked the methods an impl
writes against the trait (D140) but never that the impl writes each one the
trait leaves without a default. An impl of `T` omitting `n` was accepted;
the dyn vtable builder (CodegenTraits.w) then filled the slot with null, and
`x.n()` through `&dyn T` trapped at run time (rc=133) with no message.

check_trait_impl_complete refuses it at the impl: "impl of `T` for `A` does
not define `n`, which the trait declares with no default body".

Test: test/compile_errors/err_1002_impl_missing_trait_method.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.

Omitted impl method becomes a null vtable slot: dyn call traps (rc=133) with zero diagnostic

1 participant