Skip to content

D185 (#2960): the bracket comprehension over Option and Result yields the carrier; the yield expression form is retired (§13.6a) - #2990

Merged
ehartford merged 1 commit into
mainfrom
d185-comprehensions
Nov 2, 2026
Merged

ehartford merged 1 commit into
mainfrom
d185-comprehensions

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Item 2 of bridge-the-impl-gap.md, ruled by Eric 2026-11-02 (D185). The parser builds the clause match beside a bracket comprehension; Sema takes it when the first clause is an Option or Result and types the result as the carrier of the element; MIR lowers it as the match. Guards may follow any clause. The yield expression forms are refused naming the bracket form; the statement form stays. Fixtures updated and added; conformance row D185 flips. Battery to follow.

@ehartford
ehartford force-pushed the d185-comprehensions branch from 4dc9fab to c7ddcd7 Compare November 2, 2026 22:20
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery green on c7ddcd7 (out/battery/status.txt: rc= green). From the first red: the spec test, behav_for_comprehension and the debug-alloc fixture spelled the retired yield form and now spell the bracket form; a bare variant first clause under a Result/Option demand is typed by the match checker (#722); two census rises removed.

…and Result yields the carrier of the element (§13.6, §13.6a)

A bracket comprehension whose first clause iterates an Option or a
Result is the short-circuiting chain: the parser builds the clause
match beside it (build_comprehension_match, with each clause's guard as
a guard clause) as it does for a `for`, Sema checks the first iterable
once and, seeing a carrier, checks that match and types the expression
as the carrier of the element, never a List of one; MIR lowers it as the
match. A guard may now follow any clause of a bracket comprehension (the
collection form already lowered per-clause filters). The
`for x in a; y in b: yield e` expression form and the one-clause
`for x in opt: yield e` are retired (Law 9), each refused naming the
bracket form; the statement form stays.

Fixtures: behav_d185_bracket_option_guard; the four fixtures that used
the yield form now spell the bracket form; err_d185_yield_form_retired,
err_d185_one_clause_yield_retired. Conformance row D185 flips.
@ehartford
ehartford force-pushed the d185-comprehensions branch from c7ddcd7 to 03f0b14 Compare November 2, 2026 22:41
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery green again on 03f0b14, rebased onto main after D183 and D191 (the only conflict was an inventory row).

@ehartford
ehartford merged commit 32bf443 into main Nov 2, 2026
@ehartford
ehartford deleted the d185-comprehensions branch November 2, 2026 22:58
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