#39: MMD calls the wrong sub
-------------------+--------------------------------------------------------
 Reporter:  rgrjr  |        Type:  bug   
   Status:  new    |    Priority:  normal
Milestone:         |   Component:  core  
  Version:         |    Severity:  medium
 Keywords:         |        Lang:        
    Patch:         |    Platform:        
-------------------+--------------------------------------------------------

Comment(by rgrjr):

 I am still seeing the equivalent failure in r49616, but it turns out
 this is *not* an MMD failure; it fails due to bypassing MMD altogether.
 The real problem is that r33806 causes ".const 'Sub' ..." to behave
 differently:  When given the name of a multisub in r33805, it loads the
 register with the multisub, but in r33806 it loads the first component
 sub, which (if that is not the appropriate method) makes it look like an
 incorrect dispatch.  I can't imagine this change was intended.

 The following test case is based on t/pmc/multidispatch.t case 9,
 with the addition of two other ways (that should be equivalent) of
 finding the "foo" multi.  Please ignore the enormous tarballs.  ;-}

 {{{
 #! perl

 use strict;
 use warnings;
 use lib qw( . lib ../lib ../../lib );

 use Test::More;
 use Parrot::Test::Util 'create_tempfile';

 use Parrot::Test tests => 1;

 pir_output_is( <<'CODE', <<'OUTPUT', '.const of a multisub gets the
 multi');
 .sub foo :multi(_, Integer)
     .param pmc first
     .param pmc second
     print "(_, Int) method:  "
     print first
     print ', '
     print second
     print "\n"
 .end
 .sub foo :multi(_, Float)
     .param pmc first
     .param pmc second
     print "(_, Float) method:  "
     print first
     print ', '
     print second
     print "\n"
 .end
 .sub main :main
     say "Direct calls use the multi."
     $P0 = new ['Float']
     $P0 = 9.5
     foo(1, $P0)
     $P1 = new ['Integer']
     $P1 = 3
     foo(1, $P1)
     say ".const 'Sub' should also use the multi."
     .const 'Sub' foo_const = 'foo'
     print "got "
     print foo_const
     print " type "
     $S0 = typeof foo_const
     say $S0
     foo_const(1, $P0)
     say "And so should get_global."
     .local pmc foo_sub
     foo_sub = get_global 'foo'
     print "got "
     print foo_sub
     print " type "
     $S0 = typeof foo_sub
     say $S0
     foo_sub(1, $P0)
 .end
 CODE
 Direct calls use the multi.
 (_, Float) method:  1, 9.5
 (_, Int) method:  1, 3
 .const 'Sub' should also use the multi.
 got foo type MultiSub
 (_, Float) method:  1, 9.5
 And so should get_global.
 got foo type MultiSub
 (_, Float) method:  1, 9.5
 OUTPUT
 }}}

-- 
Ticket URL: <https://trac.parrot.org/parrot/ticket/39#comment:4>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets

Reply via email to