#1718: `NameSpace.add_sub($name, &sub)` does not honor given name for methods
--------------------+-------------------------------------------------------
 Reporter:  Austin  |        Type:  bug   
   Status:  new     |    Priority:  normal
Milestone:          |   Component:  none  
  Version:  2.5.0   |    Severity:  medium
 Keywords:          |        Lang:        
    Patch:          |    Platform:        
--------------------+-------------------------------------------------------
 The namespace.add_sub method accepts a name parameter for the sub object.

 When passed a sub object that has the :method flag set, the given name
 parameter is ignored in favor of the name compiled into the sub object.
 {{{
 (git:master) ~/kakapo$ cat src/Pmc/test.nqp
 module A {
         method a() { say("a"); }

 }

 class B {
         INIT {
                 my $A := pir::get_hll_namespace__pp( pir::split('::', 'A')
 );
                 my &a := pir::inspect__pps($A, 'methods')<a>;

                 my $B := pir::get_hll_namespace__pp( pir::split('::', 'B')
 );
                 $B.add_sub('foo', &a);
         }
 }

 my $b := B.new;
 $b.a;
 $b.foo;(git:master) ~/kakapo$ parrot-nqp src/Pmc/test.nqp
 a
 Method 'foo' not found for invocant of class 'B'
 current instr.: '_block11' pc 95 (EVAL_1:34)
 called from Sub 'parrot;HLL;Compiler;_block470' pc 24271 (ext/nqp-
 rx/src/stage0/HLL-s0.pir:7848)
 called from Sub 'parrot;HLL;Compiler;eval' pc 24151 (ext/nqp-
 rx/src/stage0/HLL-s0.pir:0)
 called from Sub 'parrot;PCT;HLLCompiler;evalfiles' pc 1500
 (compilers/pct/src/PCT/HLLCompiler.pir:761)
 called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1702
 (compilers/pct/src/PCT/HLLCompiler.pir:869)
 called from Sub 'parrot;NQP;Compiler;main' pc 88625 (ext/nqp-
 rx/src/stage0/NQP-s0.pir:24151)
 }}}

 See in particular the code at
 
[http://trac.parrot.org/parrot/browser/tags/RELEASE_2_6_0/src/pmc/namespace.pmc#L173
 namespace.pmc, line 173] which I think is a bug.

-- 
Ticket URL: <https://trac.parrot.org/parrot/ticket/1718>
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