On Wed, Sep 17, 2008 at 10:01:12AM -0500, Patrick R. Michaud wrote: > On Tue, Sep 16, 2008 at 09:01:06PM -0700, Stephen Simmons wrote: > > Using the more elaborate version of the testcase behind #58294, which has a > > two and a three argument version of max, what use to compile and execute > > incorrectly before the bug fix now compiles and segfaults. I suspect this > > has nothing to do with the changes that fixed #58294, and everything to do > > with recent MMD changes. But that's speculation > > I've stripped it down to the max(a,b) and max(a,b,c) definitions and one > > three-arg call, though a two-arg call produces a similar result. The result > > is: > > > > sully:perl6 stephensimmons$ perl6 experiment/max3.p6 > > Null PMC access in invoke() > > current instr.: '_block11' pc 44 (EVAL_14:19) > > I think there's something wrong with Rakudo's code generation > here; see the --target=pir output for max3.p6. [...] > ## 2 argument form > .sub "max" :multi() :lexid("25") :outer("23") > ## 3 argument form > .sub "max" :multi() :lexid("33") :outer("23") > > Those two empty :multi() declarations look very suspicious to me, > but I'm not familiar enough with the new MMD implementation to know > how it's supposed to work.
I just checked with Jonathan on IRC, and he says the empty :multi() declarations are correct here. So that's not the problem. Actually, I suspect the problem may be that 'max' is already a builtin function in Perl, and that the conflict comes because the builtins (written in PIR) are still using Parrot's MultiSub while the ones written in Perl 6 are using the new Perl6MultiSub implementation. If I change the function name in max3.p6 to be something other than 'max', it appears to work: $ cat max3.p6 multi sub max3($a, $b) { if defined $a && defined $b { if $a >= $b { return $a } else { return $b } } elsif defined $a { return $a } elsif defined $b { return $b } else { return undef } } multi sub max3($a, $b, $c) { return max3(max3($a, $b), $c); } say "6 <" ~ max3(9,2,1) ~ ">"; $ ./parrot perl6.pbc max3.p6 6 <9> $ So, this problem should be "fixed" when we get the builtins to be written in Perl 6 (or at least using Perl6MultiSubs). Pm