Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next on last iteration of loop injects Mu into return value and fouls termination test #6237

Open
p6rt opened this issue May 9, 2017 · 2 comments

Comments

@p6rt
Copy link

p6rt commented May 9, 2017

Migrated from rt.perl.org#131281 (status was 'new')

Searchable as RT131281$

@p6rt
Copy link
Author

p6rt commented May 9, 2017

From @skids

There are some misbehaviors when a next clause is encountered on what would be the last iteration of a loop construct. An extra Mu is injected into the return value for that iteration, and the termination test may be bypassed.

skids​: m​: my $b; (loop ($b = 4; $b; $b--) { next if $b == 1; $_ }).note
(02​:05​:08 PM) camelia​: rakudo-moar 6bb1b5​: OUTPUT​: «((Any) (Any) (Any) (Mu) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (A…»

m​: my $b; (loop ($b = 4; $b > 0; $b--) { next if $b == 1; $b }).note # version without escaping the termination condition
(02​:13​:17 PM) camelia​: rakudo-moar 6bb1b5​: OUTPUT​: «(4 3 2 (Mu))␤»
(02​:13​:25 PM) skids​: still have that Mu.

@p6rt
Copy link
Author

p6rt commented May 9, 2017

From @skids

On Tue, 09 May 2017 11​:17​:23 -0700, bri@​abrij.org wrote​:

There are some misbehaviors when a next clause is encountered on what
would be the last iteration of a loop construct. An extra Mu is
injected into the return value for that iteration, and the termination
test may be bypassed.

skids​: m​: my $b; (loop ($b = 4; $b; $b--) { next if $b == 1; $_
}).note
(02​:05​:08 PM) camelia​: rakudo-moar 6bb1b5​: OUTPUT​: «((Any) (Any) (Any)
(Mu) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any)
(Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any)
(Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any)
(Any) (Any) (Any) (Any) (Any) (A…»

m​: my $b; (loop ($b = 4; $b > 0; $b--) { next if $b == 1; $b }).note #
version without escaping the termination condition
(02​:13​:17 PM) camelia​: rakudo-moar 6bb1b5​: OUTPUT​: «(4 3 2 (Mu))␤»
(02​:13​:25 PM) skids​: still have that Mu.

Also seems to affect other loop constructs.
skids​: Ooh. also affect while.
(02​:19​:21 PM) skids​: m​: my $b =4; (while ($b--) { next if $b == 0; $b }).note
(02​:19​:22 PM) camelia​: rakudo-moar 6bb1b5​: OUTPUT​: «(3 2 1 (Mu) -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -6…»

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant