# New Ticket Created by "Carl Mäsak"
# Please include the string: [perl #126270]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=126270 >
<Guest56815> p6: spurt('/tmp/ABCD.txt', "A\nB\nC\nD"); for
'/tmp/ABCD.txt'.IO.lines() -> $x, $y { say "$x, then $y"; }
<camelia> rakudo-moar 0cca60: OUTPUT«spurt is disallowed in restricted
setting [...]
<Guest56815> Okay. When running that code, I get "A, then B C, then D
Too few positionals passed; expected 2 arguments but got 0 [...]
<masak> Guest56815: interesting. sounds like a bug. if there are 0
arguments then the loop should be over.
* masak tries to reproduce locally
<masak> yep, reproduced.
* masak submits rakudobug
<Guest56815> Thanks!
<masak> golfed:
<masak> m: for "A\nB\nC\nD".lines() -> $x, $y { say "$x, then $y" }
<camelia> rakudo-moar 0cca60: OUTPUT«A, then BC, then DToo few
positionals passed; expected 2 arguments but got 0 [...]
<masak> no need for &spurt :)
<jnthn> m: for |(1, 2), |(3, 4), |() -> $x, $y { say "$x, then $y" }
<camelia> rakudo-moar 0cca60: OUTPUT«1, then 23, then 4»
<jnthn> Hm, not that... :)
<masak> m: for "A\nB\nC\nD".lines() -> $x { say $x }
<camelia> rakudo-moar 0cca60: OUTPUT«ABCD»
<masak> m: for [1,2,3,4] -> $x, $y { say "$x, then $y" }
<camelia> rakudo-moar 0cca60: OUTPUT«1, then 23, then 4»
<masak> ok, so something fishy with lines()
<jnthn> m: my \i = "A\nB\nC\nD".lines.iterator; my @x; (say
i.push-exactly(@x, 2)) xx 3
<camelia> rakudo-moar 0cca60: OUTPUT«220»
<jnthn> m: my \i = <A B C D>.iterator; my @x; (say i.push-exactly(@x, 2)) xx 3
<camelia> rakudo-moar 0cca60: OUTPUT«22»
<jnthn> That's the discrepancy. The push-many in the lines iterator is
returning 0 when it should return IterationEnd
* masak adds that to the ticket