Skip to content

`repeat` gets parsed as a listop if there's no `while` or `until` #141

Open
masak opened this Issue Aug 8, 2012 · 0 comments

1 participant

@masak
Collaborator
masak commented Aug 8, 2012
<masak> std: repeat { say "OH HAI" }
<p6eval> std f43a358: OUTPUT«===SORRY!===␤Undeclared routine:␤ 'repeat' used at line 1␤Check failed␤FAILED 00:00 41m␤»
<masak> hm.
<jnthn> did you mean loop?
<masak> jnthn: no, I meant to check what happens if I do 'repeat' without the 'until' or 'while' after the block.
<masak> std: repeat { say "OH HAI" } while True
<p6eval> std f43a358: OUTPUT«ok 00:00 41m␤»
<masak> I'm surprised it parses as a listop when the 'while' is not there.
<jnthn> Hmmmm.
<jnthn> Surely it doesn't backtrack there...
<masak> right.
<jnthn> std: repeat { my $x; say "OH HAI" }
<p6eval> std f43a358: OUTPUT«===SORRY!===␤Undeclared routine:␤ 'repeat' used at line 1 [...] Check failed␤FAILED 00:00 42m␤»
<jnthn> r: repeat { say "OH HAI" } # curious
<p6eval> rakudo 34e8d4: OUTPUT«===SORRY!===␤CHECK FAILED:␤Undefined routine '&repeat' called (line 1)␤»
<PerlJam> That could make for some interesting code.
<PerlJam> r: sub repeat { $^a.() }; repeat { say "hi" }
<p6eval> rakudo 34e8d4: OUTPUT«hi␤»
<jnthn> Wow!
<PerlJam> r:  sub repeat { $^a.() }; repeat { say "hi" }; my $i = 0; repeat { say "foo" } while $i++ < 3;
<p6eval> rakudo 34e8d4: OUTPUT«hi␤foo␤foo␤foo␤foo␤»
<PerlJam> good for obfuscation I guess
<masak> was gonna say.
<masak> I feel 'repeat' is a badly chosen name for that sub :P
<jnthn> I think the parser is gonna need to commit after seeing repeat, fwiw
* masak submits stdbug
* masak submits rakudobug
<masak> n: repeat { say "OH HAI" }
<p6eval> niecza v19-15-g051783d: OUTPUT«===SORRY!===␤␤Undeclared routine:␤     'repeat' used at line 1 [...] Check failed [...]
* masak submits nieczabug
* jnthn will wait for an STD fix and steal that
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.