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
D69: g.pull() of a generator whose arguments are views (an ephemeral generator value) #1732
Spec: §13.4 Pulling (D69) forbids pulling a generator that yields views of its own locals; a generator whose arguments are views (gen fn lex(src: &str) -> Token, gen fn nonempty(lines: &Vec[str]) -> &str) may be pulled, and the pulled iterator is then as ephemeral as the generator value (§5.5).
The first g.pull() (#1725, branch gen-push-pull) implements pull as std.task.gen_pull(g) -> Pulled[T]: a heap PullCore whose closure owns the generator value until the coroutine consumes it. When the generator value is ephemeral, that closure is an escaping closure capturing an ephemeral value ("escaping closure cannot capture ephemeral references" inside std.task), and Pulled[T] is not ephemeral, so nothing would stop the pulled iterator from outliving the viewed argument.
Needed: a pulled iterator whose ephemerality follows the generator value's (Sema decides it at the g.pull() call: the result type is ephemeral exactly when the generator value is), and a gen_pull body the escape check accepts for that case.
Until then g.pull() on an ephemeral generator value is a compile error naming this issue.
Repro:
gen fn nonempty(lines: &Vec[str]) -> &str:
for line in lines:
if line.len() > 0:
yield line
fn main:
let v: Vec[str] = ["a".clone(), "".clone(), "c".clone()]
var p = nonempty(&v).pull()
print(p.next().unwrap())
Expected: prints a. Actual: compile error citing this issue.
Fixed on main by 9307016 (#1965): g.pull() of a generator whose arguments are views is allowed; the pulled iterator carries the generator's origins (gen_pull_view_nodes) and Pulled[&T].next() views the receiver's origins, so the pulled iterator is as ephemeral as the generator value (§13.4, §5.5). Fixtures behav_gen_pull_view_args / err_gen_pull_view_escapes / err_gen_pull_view_mutated. Battery green.
Activity
D69: g.pull() — a generator stepped by next() on its own fiber (§13.4, …
D69: g.pull() — a generator stepped by next() on its own fiber (§13.4, …
D69: g.pull() — a generator stepped by next() on its own fiber (§13.4, …
D69: g.pull() — a generator stepped by next() on its own fiber (§13.4, …
D69: g.pull() — a generator stepped by next() on its own fiber (§13.4, …
D69: g.pull() — a generator stepped by next() on its own fiber (#1748)
g.pull(): a generic instance names its own declaration; a pulled elem…
WIP: D69 pull and stages over a generator whose arguments are views (#…
g.pull(): a generic instance names its own declaration; a pulled elem…
WIP: D69 pull and stages over a generator whose arguments are views (#…
g.pull(): a generic instance names its own declaration; a pulled elem…
WIP: D69 pull and stages over a generator whose arguments are views (#…
g.pull(): a generic instance names its own declaration; a pulled elem…
D70 namespaced types reachable when shadowed (#1757); generator stage…
ehartford commentedon Oct 3, 2026
Fixed on main by 9307016 (#1965):
g.pull()of a generator whose arguments are views is allowed; the pulled iterator carries the generator's origins (gen_pull_view_nodes) andPulled[&T].next()views the receiver's origins, so the pulled iterator is as ephemeral as the generator value (§13.4, §5.5). Fixtures behav_gen_pull_view_args / err_gen_pull_view_escapes / err_gen_pull_view_mutated. Battery green.