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
D142: a range on the left of a pipeline does not iterate (no iter() on Range[T]) #2544
D142 (§13.5) rules that a sequence on the left of |> iterates by the rule for uses. A range is a sequence for iterates, but it has no .iter() method, which is what the implemented rule looks for:
fn main:
let a = (0..10) |> map(it * 2) |> filter(it > 4) |> collect[List]()
print(f"{a.len()}")
v0.15.3.0-g5e0bd9076: error: undefined variable at it (the stage sees no iterator); (0..10).map(it * 2) says unknown method 'map' for type 'Range[isize]'.
Expected: the pipeline iterates the range, as for i in 0..10 does. The same shape as a slice's iter() (D142): a std RangeIter[T] over the range with an Iter[T] impl, and Sema dispatching r.iter(), for (kept on the built-in counter loop) and |> over a Range[T] to it. A gen fn's value in a pipeline is a separate question: for x in g is g.each(body) (D69), push-based, so g |> map(..) needs an adapter over each or a ruling that generators are consumed by for only.
Activity
The intrinsic iterator adapters retire: no source reaches them (#2220 …
D144 completed (a bare local observes), D145 ranges in pipelines (#2544…