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: a comprehension clause over a generator (§13.6: [f(x) for x in g]) #1727
Spec: §13.6 (a comprehension clause's for PATTERN in EXPR is §13.5's iteration) with §13.4 (D69).
[x * 2 for x in upto(3)] where upto is a gen fn. Before D69 the program compiled and hung at run time (the pull-model next() path never finished); with the D69 push lowering (gen-push-impl) a comprehension clause over a Gen[T] is not lowered, so it is a compile error citing this issue.
Expected: the clause runs the remaining clauses and the leaf as the body each calls (the same closure lowering as for x in g, lower_for_gen), stopping never (a comprehension consumes the whole generator).
Repro:
gen fn upto(n: i32) -> i32:
for i in 0..n:
yield i
fn main:
let v = [x * 2 for x in upto(3)]
print(v.len())
Workaround: var v: Vec[i32] = Vec.new() + for x in upto(3): v.push(x * 2), or upto(3) |> map(it * 2) |> collect[Vec]().
Activity
D69: generators lower as calls — a gen fn calls the consumer's loop b…
D69 tests: push generators — loops in generators, stops, views, pipel…
D69: generators lower as calls — a gen fn calls the consumer's loop b…
D69 tests: push generators — loops in generators, stops, views, pipel…
D69: a generator's views are live for the whole loop over it — the bo…
Sema: a comprehension clause over a suspending generator records its …
D69: generators lower as calls — a gen fn calls the consumer's loop b…
D69 tests: push generators — loops in generators, stops, views, pipel…
comprehension: the collection being built is a statement temporary — …
D69: a comprehension clause over a generator runs the rest of the com…
D69: a generator's views are live for the whole loop over it — the bo…
Sema: a comprehension clause over a suspending generator records its …
D69: generators lower as calls — a gen fn calls the consumer's loop b…
D69 tests: push generators — loops in generators, stops, views, pipel…
comprehension: the collection being built is a statement temporary — …
4 remaining items
D69 tests: push generators — loops in generators, stops, views, pipel…
comprehension: the collection being built is a statement temporary — …
D69: a comprehension clause over a generator runs the rest of the com…
D69: a generator's views are live for the whole loop over it — the bo…
Sema: a comprehension clause over a suspending generator records its …
D69: generators lower as calls — a gen fn calls the consumer's loop b…
D69 tests: push generators — loops in generators, stops, views, pipel…
comprehension: the collection being built is a statement temporary — …
D69: a comprehension clause over a generator runs the rest of the com…
D69: a generator's views are live for the whole loop over it — the bo…
Sema: a comprehension clause over a suspending generator records its …
D69: generators lower as calls — push generators, std.generators pipe…
D69: g.pull() — a generator stepped by next() on its own fiber (#1748)
D69 follow-ups: generic and method gen fn, comprehensions and goto ov…