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

Something wrong with LEAVE phaser in while loop #3324

Open
p6rt opened this issue Feb 2, 2014 · 8 comments
Open

Something wrong with LEAVE phaser in while loop #3324

p6rt opened this issue Feb 2, 2014 · 8 comments
Labels
JVM Related to Rakudo-JVM testcommitted

Comments

@p6rt
Copy link

p6rt commented Feb 2, 2014

Migrated from rt.perl.org#121145 (status was 'open')

Searchable as RT121145$

@p6rt
Copy link
Author

p6rt commented Feb 2, 2014

From mark@kli.org

 

 
 
 
 
  <clsn> perl6​: my $i=0; while $i < 6 { LEAVE { last }; say
  $i++; }

  <camelia> rakudo-parrot 535d91​: OUTPUT«===SORRY!===␤Error
  while compiling op p6return​: Operation 'p6return' requires 1
  operands, but got 2␤»

  <camelia> ..rakudo-jvm 535d91, rakudo-moar 535d91, niecza
  v24-109-g48a8de3​: OUTPUT«0␤»

 

 

 

@p6rt
Copy link
Author

p6rt commented Nov 23, 2014

From @usev6

Well, the error for rakudo.parrot is gone​:

$ perl6-p -e 'my $i=0; while $i < 3 { LEAVE { last }; say $i++; }'
0

But there is still something wrong with the LEAVE phaser in a while statement. First, the above command has a different output on rakudo.moar and rakudo.jvm​:

$ perl6-m -e 'my $i=0; while $i < 3 { LEAVE { last }; say $i++; }'
0
1
2

Furthermore it looks like the statement in the LEAVE block isn't executed at all (but rakudo.parrot still breaks out of the while statement)​:

$ perl6-p -e 'my $i=0; while $i < 3 { LEAVE { say "bye!" }; say $i++; }'
0

$ perl6-m -e 'my $i=0; while $i < 3 { LEAVE { say "bye!" }; say $i++; }'
0
1
2

Or even with 'redo'​:

$ perl6-p -e 'my $i=0; while $i < 3 { LEAVE { redo }; say $i++; }'
0

$ perl6-m -e 'my $i=0; while $i < 3 { LEAVE { redo }; say $i++; }'
0
1
2

1 similar comment
@p6rt
Copy link
Author

p6rt commented Nov 23, 2014

From @usev6

Well, the error for rakudo.parrot is gone​:

$ perl6-p -e 'my $i=0; while $i < 3 { LEAVE { last }; say $i++; }'
0

But there is still something wrong with the LEAVE phaser in a while statement. First, the above command has a different output on rakudo.moar and rakudo.jvm​:

$ perl6-m -e 'my $i=0; while $i < 3 { LEAVE { last }; say $i++; }'
0
1
2

Furthermore it looks like the statement in the LEAVE block isn't executed at all (but rakudo.parrot still breaks out of the while statement)​:

$ perl6-p -e 'my $i=0; while $i < 3 { LEAVE { say "bye!" }; say $i++; }'
0

$ perl6-m -e 'my $i=0; while $i < 3 { LEAVE { say "bye!" }; say $i++; }'
0
1
2

Or even with 'redo'​:

$ perl6-p -e 'my $i=0; while $i < 3 { LEAVE { redo }; say $i++; }'
0

$ perl6-m -e 'my $i=0; while $i < 3 { LEAVE { redo }; say $i++; }'
0
1
2

@p6rt
Copy link
Author

p6rt commented Nov 23, 2014

@usev6 - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Aug 3, 2015

From @coke

On Sun Nov 23 00​:48​:59 2014, bartolin@​gmx.de wrote​:

Well, the error for rakudo.parrot is gone​:

$ perl6-p -e 'my $i=0; while $i < 3 { LEAVE { last }; say $i++; }'
0

But there is still something wrong with the LEAVE phaser in a while
statement. First, the above command has a different output on
rakudo.moar and rakudo.jvm​:

$ perl6-m -e 'my $i=0; while $i < 3 { LEAVE { last }; say $i++; }'
0
1
2

Furthermore it looks like the statement in the LEAVE block isn't
executed at all (but rakudo.parrot still breaks out of the while
statement)​:

$ perl6-p -e 'my $i=0; while $i < 3 { LEAVE { say "bye!" }; say $i++;
}'
0

$ perl6-m -e 'my $i=0; while $i < 3 { LEAVE { say "bye!" }; say $i++;
}'
0
1
2

Or even with 'redo'​:

$ perl6-p -e 'my $i=0; while $i < 3 { LEAVE { redo }; say $i++; }'
0

$ perl6-m -e 'my $i=0; while $i < 3 { LEAVE { redo }; say $i++; }'
0
1
2

15​:53 <[Coke]> r​: my $i=0; while $i < 6 { LEAVE { last }; say $i++; }
15​:53 <camelia> rakudo-{moar,jvm} a38b59​: OUTPUT«0␤»

This seems fine. To avoid confusion about whether the first loop should be saying 0 or 1, try this​:

15​:56 <[Coke]> r​: my $i=0; while $i < 6 { LEAVE { last }; $i = $i + 1; say $i }
15​:56 <camelia> rakudo-{moar,jvm} a38b59​: OUTPUT«1␤»

The original ticket was about parrot, but that's not currently a supported backend.

Closable with tests.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Aug 3, 2015

From @coke

On Mon Aug 03 13​:00​:39 2015, coke wrote​:

On Sun Nov 23 00​:48​:59 2014, bartolin@​gmx.de wrote​:

Well, the error for rakudo.parrot is gone​:

$ perl6-p -e 'my $i=0; while $i < 3 { LEAVE { last }; say $i++; }'
0

But there is still something wrong with the LEAVE phaser in a while
statement. First, the above command has a different output on
rakudo.moar and rakudo.jvm​:

$ perl6-m -e 'my $i=0; while $i < 3 { LEAVE { last }; say $i++; }'
0
1
2

Furthermore it looks like the statement in the LEAVE block isn't
executed at all (but rakudo.parrot still breaks out of the while
statement)​:

$ perl6-p -e 'my $i=0; while $i < 3 { LEAVE { say "bye!" }; say $i++;
}'
0

$ perl6-m -e 'my $i=0; while $i < 3 { LEAVE { say "bye!" }; say $i++;
}'
0
1
2

Or even with 'redo'​:

$ perl6-p -e 'my $i=0; while $i < 3 { LEAVE { redo }; say $i++; }'
0

$ perl6-m -e 'my $i=0; while $i < 3 { LEAVE { redo }; say $i++; }'
0
1
2

15​:53 <[Coke]> r​: my $i=0; while $i < 6 { LEAVE { last }; say $i++; }
15​:53 <camelia> rakudo-{moar,jvm} a38b59​: OUTPUT«0␤»

This seems fine. To avoid confusion about whether the first loop
should be saying 0 or 1, try this​:

15​:56 <[Coke]> r​: my $i=0; while $i < 6 { LEAVE { last }; $i = $i +
1; say $i }
15​:56 <camelia> rakudo-{moar,jvm} a38b59​: OUTPUT«1␤»

The original ticket was about parrot, but that's not currently a
supported backend.

Closable with tests.

Whoops, here are the other examples - the bye sample works fine...

16​:01 <[Coke]> r​: my $i=0; while $i < 3 { LEAVE { say "bye!" }; say $i++; }
16​:01 <camelia> rakudo-{moar,jvm} a38b59​: OUTPUT«0␤bye!␤1␤bye!␤2␤bye!␤»

And the redo, as expected, now loops infinitely (deliberately redoing the block each time after completing the block...).

16​:02 <[Coke]> r​: my $i=0; while $i < 3 { LEAVE { redo }; say $i++; }
16​:02 <camelia> rakudo-jvm a38b59​:
OUTPUT«0␤1␤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…»
16​:02 <camelia> ..rakudo-moar a38b59​:
OUTPUT«(timeout)0␤1␤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…»

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Aug 3, 2015

From @usev6

< bartolin_> r​: my $str; my $i = 0; while $i < 2 { LEAVE { last }; $i++; $str ~= ~$i; }; say $str; $str = ""; $i = 0; while $i < 2 { LEAVE { $str ~= "leaving" }; $i++; $str ~= ~$i; }; say $str
<+camelia> rakudo-moar a38b59​: OUTPUT«1␤1leaving2leaving␤»
<+camelia> ..rakudo-jvm a38b59​: OUTPUT«1␤␤»
< bartolin_> [Coke]​: ^^ alas, there still seems to be something wrong on JVM with RT #​121145
< [Coke]> bartolin_​: hokay.
< [Coke]> We can at least add a test and make sure we don't regress on moar - don't have to get JVM 100% before christmas.
< bartolin_> [Coke]​: I'll add a test for that ... what you said

Test was added to S04-phasers/in-loop.t with commit Raku/roast@7ce647a18a

The strange thing is, that the second while loop (which fails on JVM, see above) works as expected if executed "stand alone"​:

$ perl6-j -e 'my $str = ""; my $i = 0; while $i < 2 { LEAVE { $str ~= "leaving" }; $i++; $str ~= ~$i; }; say $str'
1leaving2leaving

1 similar comment
@p6rt
Copy link
Author

p6rt commented Aug 3, 2015

From @usev6

< bartolin_> r​: my $str; my $i = 0; while $i < 2 { LEAVE { last }; $i++; $str ~= ~$i; }; say $str; $str = ""; $i = 0; while $i < 2 { LEAVE { $str ~= "leaving" }; $i++; $str ~= ~$i; }; say $str
<+camelia> rakudo-moar a38b59​: OUTPUT«1␤1leaving2leaving␤»
<+camelia> ..rakudo-jvm a38b59​: OUTPUT«1␤␤»
< bartolin_> [Coke]​: ^^ alas, there still seems to be something wrong on JVM with RT #​121145
< [Coke]> bartolin_​: hokay.
< [Coke]> We can at least add a test and make sure we don't regress on moar - don't have to get JVM 100% before christmas.
< bartolin_> [Coke]​: I'll add a test for that ... what you said

Test was added to S04-phasers/in-loop.t with commit Raku/roast@7ce647a18a

The strange thing is, that the second while loop (which fails on JVM, see above) works as expected if executed "stand alone"​:

$ perl6-j -e 'my $str = ""; my $i = 0; while $i < 2 { LEAVE { $str ~= "leaving" }; $i++; $str ~= ~$i; }; say $str'
1leaving2leaving

@p6rt p6rt added JVM Related to Rakudo-JVM testcommitted labels Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JVM Related to Rakudo-JVM testcommitted
Projects
None yet
Development

No branches or pull requests

1 participant