You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
std.generators stages reject a generator whose arguments are views (escaping closure cannot capture ephemeral references) #1737
Spec: §13.3 / §13.4 (the ordered stages accept a Gen[T]); §5.5 (ephemeral values).
A pipeline over a generator whose arguments are views is rejected inside std.generators:
use std.generators.{map, take, collect}
gen fn over(xs: &Vec[i64]) -> &i64:
for x in xs:
yield x
fn main:
let v: Vec[i64] = [4, 5, 6]
let firsts = over(&v) |> map(it * 2) |> take(2) |> collect[Vec]()
print(firsts.len())
Same on gen-push-impl. A stage over an ephemeral generator is itself ephemeral (it holds the generator), and the chain is consumed within the statement, so the program is valid; §13.4 does not exclude ephemeral generators from the stages. Related: #1732 (pull of an ephemeral generator).
When this is lifted: a stage chain over a view-holding generator must keep the generator's views live while the chain runs, as #1734 (bce516e on gen-push-fixes) does for for x in g and comprehension clauses (register_gen_loop_view_borrows) — a stage closure that mutates the viewed place would otherwise race the producer.
Fixed on main by 9307016 (#1965): std.generators stages hold the generator as a field (§12.2 forbids an escaping closure over an ephemeral; §5.2 propagates), so a stage chain over a view-holding generator keeps the views live while the chain runs; compute_expr_view_origin_mask gained the NK_STRUCT_LIT case and generic free calls now record view origins (a pre-existing hole). Fixtures behav_gen_stages_view_args / err_gen_stage_view_mutated / err_gen_stage_escapes_block. Battery green.
Activity
D69: a generator's views are live for the whole loop over it — the bo…
ehartford commentedon Sep 26, 2026
When this is lifted: a stage chain over a view-holding generator must keep the generator's views live while the chain runs, as #1734 (bce516e on gen-push-fixes) does for
for x in gand comprehension clauses (register_gen_loop_view_borrows) — a stage closure that mutates the viewed place would otherwise race the producer.D69: a generator's views are live for the whole loop over it — the bo…
D69: a generator's views are live for the whole loop over it — the bo…
D69: a generator's views are live for the whole loop over it — the bo…
D69: a generator's views are live for the whole loop over it — the bo…
D69 follow-ups: generic and method gen fn, comprehensions and goto ov…
An in-place receiver's result views what self views, not self's stora…
A generic call's result views its arguments; a struct literal carries…
WIP: D69 pull and stages over a generator whose arguments are views (#…
An in-place receiver's result views what self views, not self's stora…
A generic call's result views its arguments; a struct literal carries…
A view-returning signature records which origins it views only throug…
WIP: D69 pull and stages over a generator whose arguments are views (#…
An in-place receiver's result views what self views, not self's stora…
A generic call's result views its arguments; a struct literal carries…
A view-returning signature records which origins it views only throug…
WIP: D69 pull and stages over a generator whose arguments are views (#…
An in-place receiver's result views what self views, not self's stora…
A generic call's result views its arguments; a struct literal carries…
A view-returning signature records which origins it views only throug…
D70 namespaced types reachable when shadowed (#1757); generator stage…
ehartford commentedon Oct 3, 2026
Fixed on main by 9307016 (#1965): std.generators stages hold the generator as a field (§12.2 forbids an escaping closure over an ephemeral; §5.2 propagates), so a stage chain over a view-holding generator keeps the views live while the chain runs; compute_expr_view_origin_mask gained the NK_STRUCT_LIT case and generic free calls now record view origins (a pre-existing hole). Fixtures behav_gen_stages_view_args / err_gen_stage_view_mutated / err_gen_stage_escapes_block. Battery green.