Skip to content

with fix-ceremony: a trait impl method's return type that restates the trait's is removed (part of #3061) - #3599

Merged
ehartford merged 1 commit into
mainfrom
fix-trait-ret
Nov 24, 2026
Merged

ehartford merged 1 commit into
mainfrom
fix-trait-ret

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Part of #3061 (item 1, the case that needs no policy answer) and part of #2519 (its first example: impl One for f64: fn one() -> f64: 1.0). Both issues stay open.

impl Shape for P:                          impl Shape for P:
    fn size() -> i64: self.n        →          fn size(): self.n
    fn checked() -> Result[i64, str]:          fn checked():

The proof. The trait declares the return, and an impl method written without one has exactly that return (published before any body is checked; #3598 made the body check the same as under a written one). Sema records the written type node when it resolves to the trait's type, an alias of it included.

Where it does not fire. A method or an owner with type parameters, and an async or gen method: the contract return is not published ahead for those, so the written type is left. A free function is untouched: that is the open half of item 1.

In the tree. src/ has none. lib/std has them, reached with a standard-library file as the entry (--std lib/std/random.with: 24; lib/std/json.with: 11). That sweep is its own PR.

Test: test/internals_compiler/ceremony_fix_test.with gains a sample with a plain type, an alias, a Result, a generic owner and a free function; the rewritten sample compiles and is compared byte for byte.

Evidence at 031ea83: both compilers check the source; release build, :unit-return-review, :ceremony-census, :self-audit, :internals-compiler-tests green; battery green.

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