Skip Menu |
Report information
Id: 58392
Status: resolved
Priority: 0/
Queue: perl6

Owner: pmichaud <pmichaud [at] pobox.com>
Requestors: masak <cmasak [at] gmail.com>
Cc: viklund <johan.viklund [at] gmail.com>
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: Recursion and for loops interact badly in Rakudo
Date: Wed, 27 Aug 2008 11:53:53 +0200
To: rakudobug [...] perl.org
From: "Carl Mäsak" <cmasak [...] gmail.com>
Download (untitled) / with headers
text/plain 933b
r30589: $ cat for-loop-recursion.bug sub f($l) { return() if $l <= 0; say "entering $l"; for 1..3 { f($l-1); say "looping in $l"; } } f(2); $ ./perl6 for-loop-recursion.bug entering 2 entering 1 looping in 1 looping in 0 looping in -1 looping in 2 looping in -2 looping in -3 Something to do with local pads, perhaps? FWIW, I can trace the bug back to r29884, the first revision that gives any output at all on the above script. Here's a Perl 5 comparison: $ cat for-loop-recursion.p5 use strict; use warnings; sub f { my $l = shift; return if $l <= 0; print "entering $l\n"; for (1..3) { f($l-1); print "looping in $l\n"; } } f(2); $ perl for-loop-recursion.p5 entering 2 entering 1 looping in 1 looping in 1 looping in 1 looping in 2 entering 1 looping in 1 looping in 1 looping in 1 looping in 2 entering 1 looping in 1 looping in 1 looping in 1 looping in 2
Subject: Re: [perl #58392] Recursion and for loops interact badly in Rakudo
Date: Wed, 27 Aug 2008 16:26:00 +0200
To: perl6-compiler [...] perl.org
From: Moritz Lenz <moritz [...] casella.verplant.org>
Download (untitled) / with headers
text/plain 363b
Carl MXXsak (via RT) wrote: Show quoted text
> r30589: > $ cat for-loop-recursion.bug > sub f($l) { > return() if $l <= 0; > say "entering $l"; > for 1..3 { > f($l-1); > say "looping in $l"; > } > } > f(2);
I re-worked that as a test and added it to t/spec/S04-statements/for.t Moritz -- Moritz Lenz http://moritz.faui2k3.org/ | http://perl-6.de/
CC: Moritz Lenz <moritz [...] casella.verplant.org>
Subject: Re: [perl #58392] Recursion and for loops interact badly in Rakudo
Date: Wed, 3 Sep 2008 11:22:42 -0700
To: perl6-compiler [...] perl.org
From: chromatic <chromatic [...] wgz.org>
Download (untitled) / with headers
text/plain 465b
On Wednesday 27 August 2008 07:26:00 Moritz Lenz wrote: Show quoted text
> Carl MXXsak (via RT) wrote:
Show quoted text
> > r30589: > > $ cat for-loop-recursion.bug > > sub f($l) { > > return() if $l <= 0; > > say "entering $l"; > > for 1..3 { > > f($l-1); > > say "looping in $l"; > > } > > } > > f(2);
> > I re-worked that as a test and added it to t/spec/S04-statements/for.t
If you or Carl can provide a PIR program which exhibits he problem, I'll fix it. -- c
Download (untitled) / with headers
text/plain 394b
Attaching stripped-down PIR code -- this may or may not be what you requested, chromatic. (There are still a few Rakudo dependencies left in the PIR code. But these are all simple things, so people more versed in PIR might be able to remove these.) We can run it through Rakudo as follows: $ ./perl6 -e 'use recbug' and it produces as output 2 1 when it should really be producing 2 1 1 1
Download recbug.pir
application/octet-stream 1.1k

Message body not shown because it is not plain text.

CC: perl6-compiler [...] perl.org, Moritz Lenz <moritz [...] casella.verplant.org>
Subject: Re: [perl #58392] Recursion and for loops interact badly in Rakudo
Date: Thu, 4 Sep 2008 14:25:45 -0500
To: chromatic <chromatic [...] wgz.org>
From: "Patrick R. Michaud" <pmichaud [...] pobox.com>
Download (untitled) / with headers
text/plain 1.2k
On Wed, Sep 03, 2008 at 11:22:42AM -0700, chromatic wrote: Show quoted text
> On Wednesday 27 August 2008 07:26:00 Moritz Lenz wrote:
> > Carl MXXsak (via RT) wrote:
>
> > > r30589: > > > $ cat for-loop-recursion.bug > > > sub f($l) { > > > return() if $l <= 0; > > > say "entering $l"; > > > for 1..3 { > > > f($l-1); > > > say "looping in $l"; > > > } > > > } > > > f(2);
> > > > I re-worked that as a test and added it to t/spec/S04-statements/for.t
> > If you or Carl can provide a PIR program which exhibits he problem, I'll fix > it.
As of r37064, it's now possible to do this using the --target=pir option to rakudo: $ cat for-loop-recursion.bug sub f($l) { return() if $l <= 0; say "entering $l"; for 1..3 { f($l-1); say "looping in $l"; } } f(2); $ ./parrot perl6.pbc --target=pir --output=for.pir for-loop-recursion.bug $ ./parrot for.pir entering 2 entering 1 looping in 1 looping in 0 looping in -1 looping in 2 looping in -2 looping in -3 $ Currently the perl6.pbc has to be somewhere where load_bytecode can find it (current directory or runtime/parrot/library) -- I'm still thinking about RT #47992 before deciding when/how I want it to be installed somewhere. Pm
CC: perl6-compiler [...] perl.org, Moritz Lenz <moritz [...] casella.verplant.org>
Subject: Re: [perl #58392] Recursion and for loops interact badly in Rakudo
Date: Thu, 4 Sep 2008 15:06:28 -0500
To: chromatic <chromatic [...] wgz.org>
From: "Patrick R. Michaud" <pmichaud [...] pobox.com>
Download (untitled) / with headers
text/plain 327b
On Thu, Sep 04, 2008 at 02:25:45PM -0500, Patrick R. Michaud wrote: Show quoted text
> As of r37064, it's now possible to do this using the --target=pir > option to rakudo: > > [...]
Also, it may be worth adding judicious calls to parrot_trace(1) (a rakudo built-in function) to enable/disable tracing at appropriate points in the code. Pm
RT-Send-CC: parrot-porters [...] perl.org
Download (untitled) / with headers
text/plain 642b
Hi, Here is a pure PIR example that doesn't depend on Rakudo at all. .sub main :main $P0 = new 'Integer' $P0 = 2 'f'($P0) .end .sub 'f' .param pmc l .lex "$l", l $P0 = find_lex "$l" if $P0 <= 0 goto ret print "entering " $P1 = find_lex "$l" say $P1 $I0 = 1 for: if $I0 > 3 goto for_end '_block1'() inc $I0 goto for for_end: ret: .end .sub '_block1' :outer('f') $P2 = find_lex "$l" $P3 = new 'Integer' $P3 = $P2 - 1 'f'($P3) print "looping in " $P4 = find_lex "$l" say $P4 .end Gives the same erroneous output as the Rakudo program. Jonathan
Subject: Re: [perl #58392] Recursion and for loops interact badly in Rakudo
Date: Sat, 25 Oct 2008 01:08:31 +1100
To: perl6-bugs-followup [...] perl.org
From: "Илья" <forihrd [...] gmail.com>
Download (untitled) / with headers
text/plain 1.2k
Hi there! First of all, please, excuse my bad English. Again :) This bug still there, in spate of two stable realize of the Parrot. It`s block our progress on the HTML::Template porting in November project and correct realization of is_deeply in our Test.pm :( Unfortunately I am not pir or C or anything but Perl programmer(not the professional one). I can wright test for that if need. If any one have time and can help with that, please annihilate that pesky bug. Thank you! Ilya 2008/9/12 jnthn@jnthn.net via RT <perl6-bugs-followup@perl.org>: Show quoted text
> Hi, > > Here is a pure PIR example that doesn't depend on Rakudo at all. > > .sub main :main > $P0 = new 'Integer' > $P0 = 2 > 'f'($P0) > .end > > .sub 'f' > .param pmc l > .lex "$l", l > $P0 = find_lex "$l" > if $P0 <= 0 goto ret > > print "entering " > $P1 = find_lex "$l" > say $P1 > > $I0 = 1 > for: > if $I0 > 3 goto for_end > '_block1'() > inc $I0 > goto for > for_end: > ret: > .end > > .sub '_block1' :outer('f') > $P2 = find_lex "$l" > $P3 = new 'Integer' > $P3 = $P2 - 1 > 'f'($P3) > print "looping in " > $P4 = find_lex "$l" > say $P4 > .end > > Gives the same erroneous output as the Rakudo program. > > Jonathan >
Subject: Re: [perl #58392] Recursion and for loops interact badly in Rakudo
Date: Fri, 24 Oct 2008 21:24:13 +0200
To: Илья <forihrd [...] gmail.com>, perl6-bug-followup [...] perl.org
From: Moritz Lenz <moritz [...] casella.verplant.org>
Download (untitled) / with headers
text/plain 692b
Илья wrote: Show quoted text
> Hi there! > First of all, please, excuse my bad English. Again :) > > This bug still there, in spate of two stable realize of the Parrot. > It`s block our progress on the HTML::Template porting in November > project and correct realization of is_deeply in our Test.pm :( > Unfortunately I am not pir or C or anything but Perl programmer(not > the professional one). I can wright test for that if need. > > If any one have time and can help with that, please annihilate that pesky bug.
To the best of my knowledge Patrick is working on this one on a branch called `lex'. Cheers, Moritz -- Moritz Lenz http://perlgeek.de/ | http://perl-6.de/ | http://sudokugarden.de/
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 411b
Now fixed in r33193: $ cat 58392 sub f($l) { return() if $l <= 0; say "entering $l"; for 1..3 { f($l-1); say "looping in $l"; } } f(2); $ ./parrot perl6.pbc 58392 entering 2 entering 1 looping in 1 looping in 1 looping in 1 looping in 2 entering 1 looping in 1 looping in 1 looping in 1 looping in 2 entering 1 looping in 1 looping in 1 looping in 1 looping in 2 $ Thanks, Pm


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org