Skip to content

#3077: a body checked on demand starts in value position, and a return mismatch names both types - #3089

Merged
ehartford merged 1 commit into
mainfrom
i3077
Nov 8, 2026
Merged

ehartford merged 1 commit into
mainfrom
i3077

Conversation

@ehartford

@ehartford ehartford commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3077.

A generic body checked on demand from inside a statement (Enumerated.next, demanded by a for over edits.enumerate()) inherited the caller's match_in_stmt_pos and stmt_pos_depth, so its tail match was checked as a statement: its arms got no demand and the None arm resolved to the last enum that declared a None variant (the compiler's own CliOneLinerMode, #3088), and the body was refused with "return type mismatch" inside the standard library. check_fn_body_with_sig_once now resets both for the body and restores them, as it already did for the caller's expectation.

The two return-mismatch leaves now say what they compared: "the function returns Option[(i64, &CeremonyEdit)], this value is CliOneLinerMode" is what found this.

Fixture: test/behavior/behav_3077_enumerate_beside_none_variant.w (fails on main, passes here). The rewriter's three index loops stay as written until a seed carries this fix: the pinned seed compiles src/ and refuses the enumerate() form.

Gate green on this layer; the battery runs once on the stack top (#3091).

…n mismatch names both types

A generic body checked on demand from inside a statement (`Enumerated.next`,
demanded by a `for` over `edits.enumerate()`) inherited the caller's
`match_in_stmt_pos` and `stmt_pos_depth`, so its tail `match` was checked as
a statement: its arms got no demand, and the `None` arm resolved to the last
enum that declared a `None` variant (the compiler's own `CliOneLinerMode`,
#3088) and the body was refused with "return type mismatch" inside the
standard library. check_fn_body_with_sig_once now resets both for the body
and restores them after, as it already does for the caller's expectation.

The two return-mismatch leaves say what they compared: "the function returns
`Option[(i64, &CeremonyEdit)]`, this value is `CliOneLinerMode`" is what
found this; the bare message did not.

The rewriter's three index loops stay as written until a seed carries this
fix: the pinned seed compiles src/ and refuses the `enumerate()` form.
@ehartford
ehartford added this pull request to stack #3092 November 8, 2026 17:35
@ehartford ehartford changed the title i3077 #3077: a body checked on demand starts in value position, and a return mismatch names both types Nov 8, 2026
@ehartford
ehartford marked this pull request as ready for review November 8, 2026 18:00
@ehartford
ehartford merged commit 82b9e0e into main Nov 8, 2026
@ehartford
ehartford deleted the i3077 branch November 8, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant