Skip to content

#3112: a written self with no type on a function outside a type is refused at the receiver - #3210

Merged
ehartford merged 1 commit into
mainfrom
i3112
Nov 10, 2026
Merged

ehartford merged 1 commit into
mainfrom
i3112

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Fixes #3112. §9.5: a top-level fn Type.name has no receiver; only the typed transition forms are accepted there. A bare mut self reached the MIR validator as an ICE on a field write, a bare move self failed in code generation, a plain self said 'method receiver mode is missing'. The parser refuses all three where written and names the two accepted spellings (the typed parameter, or the method inside impl Type:). A trait's or impl's method list is untouched (a free_fn_params flag set only by a top-level fn declaration). Fixtures err_3112_bare_{mut_,move_,}self_on_dotted_fn.

Battery history, stated plainly. Run 1 (163018e) was red on four fixtures my first version wrongly refused (bare self in trait/impl methods; fixed by the flag) plus behav_3166. Run 2 (c567f6c) was red on behav_3166 and behav_3087 only: both test binaries were linked with the pinned seed's runtime inside battery-checks (the kept binary is byte-size identical to a seed build and fails deterministically), while the lane alone ran both and passed (src/main build :behavior-tests --no-deps: 2108 files ok, 2106 cached, 2 ran). That harness race is filed as #3209 with the evidence. Run 3 on the same commit c567f6c: GREEN (wall 182 s; the lanes that had passed were served from their verdict cache, behavior-tests from the lane-alone run).

…refused at the receiver

§9.5: a top-level `fn Type.name` is an associated function with no
receiver; only the typed transition forms (`mut self: Self`) are
accepted there. A bare `mut self` parsed as an untyped parameter, and a
field write through it reached the MIR validator as an ICE ('use rvalue
type is incompatible with assign destination'); a bare `move self`
failed in code generation; a plain `self` said 'method receiver mode is
missing; compiler effects require `fn`'. The parser now refuses all
three where they are written and names the two accepted spellings: the
typed parameter, or the method inside `impl Type:` with its keyword.
(#897 fixed the same inside a type, where the keyword decides.)

Fixtures: err_3112_bare_{mut_,move_,}self_on_dotted_fn.
@ehartford
ehartford merged commit e4f7396 into main Nov 10, 2026
@ehartford
ehartford deleted the i3112 branch November 10, 2026 00:15
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.

Bare 'mut self' on a dotted method (fn T.m(mut self, …)): field write is an ICE (invalid MIR), field read loses its type — #897 sibling

1 participant