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
An iterator over a collection literal bound to a variable reads a dead temporary: var d = [1, 2] |> map(x => x * 2); d.next() is None #3004
Found while writing the §13.3 fixtures (#2943). Installed compiler (main ecbc23b):
var doubled = [1, 2] |> map(x => x * 2)
print(doubled.next().unwrap())
panic: called unwrap on None
[1, 2] |> peekable() the same. The pipeline inserts .iter() on the literal (D142), the ListIter views the temporary, and the temporary dies at the end of the statement (§21.1); the adapter bound to doubled then steps a dead list and answers None. Binding the list first (let two = [1, 2]; var d = two |> map(…)) works.
Three-way: the compiler is wrong. §21.1 rule 1 says a view that cannot outlive its statement is refused or, for a literal, the temporary lives as long as the binding (D174 establishes an owned-value demand for an unannotated binding of such a view). Expected: either the literal is materialized as a binding-lifetime temporary, or the statement is refused with the §21.1 message, never a silently empty iterator. A for over the same pipeline (for x in [1, 2] |> map(…)) is fine because the loop consumes it in the statement.
Activity
#2998, #2984, #3004, #3011, #3034, #2950: six spec-gap fixes and conf…