Navigation Menu

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

Either binding or lexicals are broken in Rakudo when recursing #1398

Closed
p6rt opened this issue Nov 13, 2009 · 14 comments
Closed

Either binding or lexicals are broken in Rakudo when recursing #1398

p6rt opened this issue Nov 13, 2009 · 14 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Nov 13, 2009

Migrated from rt.perl.org#70469 (status was 'resolved')

Searchable as RT70469$

@p6rt
Copy link
Author

p6rt commented Nov 13, 2009

From @masak

$ cat /tmp/test
class M {
  has M @​.ms is rw;
  method s($i=0) {
  $i ~ "[{ map { "{$_.s($i + 1)}" }, self.ms }]"
  }
}

my $m = M.new;
my $m2 = M.new;
$m2.ms = M.new;
$m.ms = M.new, $m2, M.new;
say $m.s;

$ perl6 /tmp/test
0[1[] 2[3[]] 4[]]

# expected output​:
# 0[1[] 1[2[]] 1[]]

<masak> jnthn​: did you fix my bug yet?
<jnthn> masak​: no.
<jnthn> ENEEDMORECOFFEE
<jnthn> I looked at it, and then ran to the coffee machine. :-)
<masak> lol
* moritz_ also found it a bit hard to follow :-)
<masak> I think by golfing it I actually made it harder to follow. :/
<masak> when it was about indentation, it was immediate that it was wrong.
<moritz_> or if you gave them names (<a b c d e>) and print that along
with the number
<masak> the structure looks like this​: Ma[Mb, Mc[Md], Me]
<masak> now, Mb and Me should be printed with the same indentation/number.
<jnthn> masak​: ugh
<masak> but they aren't.
<jnthn> masak​: Yes, I see the bug now.
* masak submits rakudobug
<jnthn> I agree it's wrong.

@p6rt
Copy link
Author

p6rt commented Nov 15, 2009

From @masak

masak (>)​:

$ cat /tmp/test
class M {
has M @​.ms is rw;
method s($i=0) {
$i ~ "[{ map { "{$_.s($i + 1)}" }, self.ms }]"
}
}

my $m = M.new;
my $m2 = M.new;
$m2.ms = M.new;
$m.ms = M.new, $m2, M.new;
say $m.s;

$ perl6 /tmp/test
0[1[] 2[3[]] 4[]]

# expected output​:
# 0[1[] 1[2[]] 1[]]

<masak> jnthn​: did you fix my bug yet?
<jnthn> masak​: no.
<jnthn> ENEEDMORECOFFEE
<jnthn> I looked at it, and then ran to the coffee machine. :-)
<masak> lol
* moritz_ also found it a bit hard to follow :-)
<masak> I think by golfing it I actually made it harder to follow. :/
<masak> when it was about indentation, it was immediate that it was wrong.
<moritz_> or if you gave them names (<a b c d e>) and print that along
with the number
<masak> the structure looks like this​: Ma[Mb, Mc[Md], Me]
<masak> now, Mb and Me should be printed with the same indentation/number.
<jnthn> masak​: ugh
<masak> but they aren't.
<jnthn> masak​: Yes, I see the bug now.
* masak submits rakudobug
<jnthn> I agree it's wrong.

<masak> rakudo​: sub f(@​a, $i=0) { $i ~ "[{map { f($_, $i + 1) }, @​a}]" }; say f([[], [[]], []])
<p6eval> rakudo 7347ec​: 0[1[] 2[3[]] 4[]]␤
* masak adds that to #​70469
<pmichaud> masak​: I suspect that's related to dispatch/binder changes, but that's just a
guess.
<masak> pmichaud​: same here.
<jnthn> Me too now I see it as a sub example.
<jnthn> masak​: Default param to blame?
<masak> jnthn​: I'll check.
<masak> rakudo​: sub f(@​a, $i) { $i ~ "[{map { f($_, $i + 1) }, @​a}]" }; say f([[], [[]], []], 0)
<p6eval> rakudo 7347ec​: 0[1[] 2[3[]] 4[]]␤
<masak> jnthn​: no.
<jnthn> masak​: Aww.
<moritz_> masak​: dammit. I was just about to put it into S06-signature/defaults.t
<jnthn> lol
<masak> :)
<pmichaud> looks to me as though a new lexpad isn't being created somehow.
<jnthn> Yeah, the problem is in there somehow.
<moritz_> masak​: and now I realize it's the wrong place, and I have no clue where to put it
<masak> moritz_​: sorry :D

@p6rt
Copy link
Author

p6rt commented Nov 15, 2009

From [Unknown Contact. See original ticket]

masak (>)​:

$ cat /tmp/test
class M {
has M @​.ms is rw;
method s($i=0) {
$i ~ "[{ map { "{$_.s($i + 1)}" }, self.ms }]"
}
}

my $m = M.new;
my $m2 = M.new;
$m2.ms = M.new;
$m.ms = M.new, $m2, M.new;
say $m.s;

$ perl6 /tmp/test
0[1[] 2[3[]] 4[]]

# expected output​:
# 0[1[] 1[2[]] 1[]]

<masak> jnthn​: did you fix my bug yet?
<jnthn> masak​: no.
<jnthn> ENEEDMORECOFFEE
<jnthn> I looked at it, and then ran to the coffee machine. :-)
<masak> lol
* moritz_ also found it a bit hard to follow :-)
<masak> I think by golfing it I actually made it harder to follow. :/
<masak> when it was about indentation, it was immediate that it was wrong.
<moritz_> or if you gave them names (<a b c d e>) and print that along
with the number
<masak> the structure looks like this​: Ma[Mb, Mc[Md], Me]
<masak> now, Mb and Me should be printed with the same indentation/number.
<jnthn> masak​: ugh
<masak> but they aren't.
<jnthn> masak​: Yes, I see the bug now.
* masak submits rakudobug
<jnthn> I agree it's wrong.

<masak> rakudo​: sub f(@​a, $i=0) { $i ~ "[{map { f($_, $i + 1) }, @​a}]" }; say f([[], [[]], []])
<p6eval> rakudo 7347ec​: 0[1[] 2[3[]] 4[]]␤
* masak adds that to #​70469
<pmichaud> masak​: I suspect that's related to dispatch/binder changes, but that's just a
guess.
<masak> pmichaud​: same here.
<jnthn> Me too now I see it as a sub example.
<jnthn> masak​: Default param to blame?
<masak> jnthn​: I'll check.
<masak> rakudo​: sub f(@​a, $i) { $i ~ "[{map { f($_, $i + 1) }, @​a}]" }; say f([[], [[]], []], 0)
<p6eval> rakudo 7347ec​: 0[1[] 2[3[]] 4[]]␤
<masak> jnthn​: no.
<jnthn> masak​: Aww.
<moritz_> masak​: dammit. I was just about to put it into S06-signature/defaults.t
<jnthn> lol
<masak> :)
<pmichaud> looks to me as though a new lexpad isn't being created somehow.
<jnthn> Yeah, the problem is in there somehow.
<moritz_> masak​: and now I realize it's the wrong place, and I have no clue where to put it
<masak> moritz_​: sorry :D

@p6rt
Copy link
Author

p6rt commented Nov 15, 2009

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

@p6rt
Copy link
Author

p6rt commented Nov 15, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S06-signature/positional.t

commit 81dba48cd7a6151ac6afc17948e68322aa721fbf
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sun Nov 15 17​:50​:47 2009 +0000

  [t/spec] test for RT #​70469, recursion and parameter binding
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;29093 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S06-signature/positional.t b/t/spec/S06-signature/positional.t
index 4cc6195..0c65e57 100644
--- a/t/spec/S06-signature/positional.t
+++ b/t/spec/S06-signature/positional.t
@@ -1,6 +1,6 @@
 use v6;
 use Test;
-plan 5;
+plan 6;
 
 sub my_first  ($x, $,  $ ) { $x };
 sub my_second ($,  $x, $ ) { $x };
@@ -32,4 +32,14 @@ is my_third( 4, 5, 6), 6, '($, $, $x) works as a signature';
     is rt60408_if(42), (42, 42), 'use of @_[0] in an "if" block (RT 60408)';
 }
 
+#?rakudo todo 'RT 70469'
+{
+
+    sub f(@a, $i) {
+        $i ~ "[{map { f($_, $i + 1) }, @a}]"
+    };
+    is f([[], [[]], []], 0), "0[1[] 1[2[]] 1[]]",
+       'recusion and parameter binding work out fine';
+}
+
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Feb 23, 2010

From @moritz

From t/spec/S06-signature/sub-ref.t​:

{
  my $mkinc = sub { my $x = 0; return sub { $x++ }; };

  my $inc1 = $mkinc();
  my $inc2 = $mkinc();

  is($inc1(), 0, "clousures​: inc1 == 0");
  is($inc1(), 1, "clousures​: inc1 == 1");
  is($inc2(), 0, "clousures​: inc2 == 0");
  is($inc2(), 1, "clousures​: inc2 == 1");
}

Rakudo now fails the last two tests, the old rakudo (now alpha) passed
them (and Perl 5.10 also passes them, if adapted to Perl 5 syntax).

It shares $x between both closures, although it shouldn't.

@p6rt
Copy link
Author

p6rt commented Feb 24, 2010

From @pmichaud

On Tue, Feb 23, 2010 at 01​:42​:44AM -0800, Moritz Lenz wrote​:

Rakudo now fails the last two tests, the old rakudo (now alpha) passed
them (and Perl 5.10 also passes them, if adapted to Perl 5 syntax).

It shares $x between both closures, although it shouldn't.

In general Rakudo is likely to still have issues with closure cloning--
this test will help a lot to track it down.

Pm

@p6rt
Copy link
Author

p6rt commented Feb 24, 2010

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Apr 19, 2010

From @masak

<masak> I found the disastrous bug.
<masak> it took all of yesterday evening. and half of the night.
<jnthn> How disasterous is it?
<masak> jnthn​: it's bad.
<jnthn> Damm.
<jnthn> Got a short test case?
<moritz_> do tell.
<jnthn> We've already been burnt by that.
<masak> rakudo​: my $t = 0; sub foo { my @​a; my &bar = { say +@​a };
unless $t++ { foo; push @​a, "OH HAI"; say +@​a; bar; } }; foo
<p6eval> rakudo 842d2b​: OUTPUT«1␤0␤»
<masak> alpha​: my $t = 0; sub foo { my @​a; my &bar = { say +@​a };
unless $t++ { foo; push @​a, "OH HAI"; say +@​a; bar; } }; foo
<p6eval> alpha 30e0ed​: OUTPUT«1␤1␤»
* masak submits rakudobug
<masak> I'll five you a minute or so :)
<moritz_> soo... &bar has some wrong lexical @​a?
<masak> rakudo​: my $t = 0; sub foo { my @​a; my &bar = { say @​a.WHICH
}; unless $t++ { foo; push @​a, "OH HAI"; say @​a.WHICH; bar; } }; foo
<p6eval> rakudo 842d2b​: OUTPUT«87969168␤88746296␤»
<masak> yep.
<masak> alpha​: my $t = 0; sub foo { my @​a; my &bar = { say @​a.WHICH };
unless $t++ { foo; push @​a, "OH HAI"; say @​a.WHICH; bar; } }; foo
<p6eval> alpha 30e0ed​: OUTPUT«47405094140536␤47405094140536␤»
<masak> the @​a in &bar gets bound to the @​a in the foo call called by
foo, not the foo call called by the outermost scope.
<moritz_> maybe related to RT #​73034, which also discusses variable
sharing in closures
* masak looks
<moritz_> that one is responsible for the man-or-boy test not working in master
<moritz_> Knuth++
<masak> I have no way to know whether mine is the same, so I'll go
ahead and submit it anyway.
<masak> they do look related.
<moritz_> maybe include a reference to that ticket
<masak> *nod*
<masak> until I can find a workaround, this bug blocks the conversion
of GGE to master.
<jnthn> pmichaud++ did at one point have a patch that got man or boy
passing again in master.
<moritz_> so why didn't he commit? did it break everything else?
<jnthn> Yes.
<masak> to heck with everything else!
<jnthn> rakudo​: my $t = 0; sub foo { my @​a; my &bar = pir​::clone({ say
+@​a }); unless $t++ { foo; push @​a, "OH HAI"; say +@​a; bar; } }; foo
<p6eval> rakudo 842d2b​: OUTPUT«1␤1␤»
<masak> jnthn++
<masak> there's the workaround. (eww!) :)

@p6rt
Copy link
Author

p6rt commented Apr 19, 2010

From @masak

<masak> pmichaud​: do you think http://rt.perl.org/rt3/Ticket/Display.html?id=74488 is
identical to http://rt.perl.org/rt3/Ticket/Display.html?id=73034 ?
<pmichaud> masak​: looking
<pmichaud> masak​: likely yes. The problem is that the closure isn't being cloned upon
assignment.
<masak> ah.
<masak> so I'll merge the tickets, then?
<pmichaud> wfm
* masak does it

@p6rt
Copy link
Author

p6rt commented Apr 19, 2010

From [Unknown Contact. See original ticket]

<masak> pmichaud​: do you think http://rt.perl.org/rt3/Ticket/Display.html?id=74488 is
identical to http://rt.perl.org/rt3/Ticket/Display.html?id=73034 ?
<pmichaud> masak​: looking
<pmichaud> masak​: likely yes. The problem is that the closure isn't being cloned upon
assignment.
<masak> ah.
<masak> so I'll merge the tickets, then?
<pmichaud> wfm
* masak does it

@p6rt
Copy link
Author

p6rt commented Apr 19, 2010

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

@p6rt
Copy link
Author

p6rt commented Jul 5, 2010

From @moritz

Tests now pass thanks to pmichaud's recent 'llsig' branch, closing ticket.

@p6rt
Copy link
Author

p6rt commented Jul 5, 2010

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jul 5, 2010
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant