Skip to content

A default trait method's declared return type is a demand on its tail as on any function's: the implicit Ok and the Result[Unit, E] fall-off (#3360) - #3362

Merged
ehartford merged 1 commit into
mainfrom
default-body-check
Nov 16, 2026
Merged

ehartford merged 1 commit into
mainfrom
default-body-check

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Exact line. SemaCheck.check_trait_default_method_body_for_impl checked the body against the return type and then ran only check_body_explicit_value_results. A value tail under Result[T, E] was accepted and no wrap recorded (implicit_ok_tail_sigs, which MIR reads, D65): internal compiler error: invalid MIR before codegen … in S.checked.

Fix: one owner for the rules. The return rules of check_fn_body_with_sig_at_settled become functions: note_option_tail_demand, check_body_result (the returned tail's effects and origins) and check_annotated_body_result (the declared type against the tail: implicit Ok, falling off a Result[Unit, E], the missing-Default and -> Never errors). The ordinary check calls all three, unchanged in behavior; the default-method check now calls the first and the third.

Not in this change (#3360 stays open): a T tail under Option[T] in a default method is still refused (the ordinary check also sets the body's tail context before checking it), and the default body's returned-tail effects are still its own. Both go with giving the two checks one body.

Test: behav_3360_default_method_implicit_ok (ICE before, ok 4 / err -2 / done after).

Battery: GREEN.

… as on any function's: the implicit Ok and the Result[Unit, E] fall-off (#3360)
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