# New Ticket Created by  Patrick R. Michaud 
# Please include the string:  [perl #40968]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=40968 >


I'm filing this as a bug report, but it could just be that
I don't understand how underscore arguments to :multi are
supposed to work.

I'm guessing that an underscore argument in :multi is
intended to indicate a "don't care" argument.  Here's a
simple test program:

    $ cat multi.pir
    .sub main :main
        .local pmc asub
        asub = get_global 'main'
    
        $P0 = new .String
        $P0 = 'hello'
        foo($P0, asub)         # call :multi(_, Sub)
    
        foo(1, asub)           # call :multi(int, Sub)
    
    .end
    
    
    .sub foo :multi(_, Sub)
        .param pmc x
        .param pmc y
        print x
        print " "
        say ":multi(_, Sub)"
    .end
    
    
    .sub foo :multi(int, Sub)
        .param int x
        .param pmc y
        print x
        print " "
        say ":multi(int, Sub)"
    .end
    
    $ ./parrot multi.pir
    hello :multi(_, Sub)
    1 :multi(int, Sub)
    $
   
Unfortunately, the "_" in :multi doesn't seem to match a
string register or string constant argument, instead producing
a "Null PMC access in invoke()" error:

    $ cat multi.pir
    .sub main :main
        .local pmc asub
        asub = get_global 'main'
    
        $P0 = new .String
        $P0 = 'hello'
        foo($P0, asub)         # call :multi(_, Sub)
    
        foo(1, asub)           # call :multi(int, Sub)
    
        foo('world', asub)     # should call :multi(_, Sub)
    .end
    
    
    .sub foo :multi(_, Sub)
        .param pmc x
        .param pmc y
        print x
        print " "
        say ":multi(_, Sub)"
    .end
    
    
    .sub foo :multi(int, Sub)
        .param int x
        .param pmc y
        print x
        print " "
        say ":multi(int, Sub)"
    .end
    
    $ ./parrot multi.pir
    hello :multi(_, Sub)
    1 :multi(int, Sub)
    Null PMC access in invoke()
    current instr.: 'main' pc 40 (multi.pir:11)
    $                                                                         
   
Is this a bug (I think it is), or does the underscore in
:multi mean something other than "any argument"?

If it's a bug, I can add a few tests to t/pmc/multisub.t .

Pm

Reply via email to