#1108: Subs in "built-in PMC" namespaces are treated as PMC methods
-----------------------------+----------------------------------------------
 Reporter:  Austin_Hastings  |        Type:  bug   
   Status:  new              |    Priority:  normal
Milestone:                   |   Component:  none  
  Version:  1.6.0            |    Severity:  medium
 Keywords:                   |        Lang:        
    Patch:                   |    Platform:        
-----------------------------+----------------------------------------------
 A sub that is declared in a namespace that matches the name of a builtin
 PMC is automatically dispatched as a method:
 {{{
 $ cat x.pir
 .sub main
     $P0 = new 'Integer'
     $P0.'foo'()
 .end

 .namespace ['Integer']

 .sub 'foo'
     say 'foo'
 .end

 $ ./parrot x.pir
 foo
 $
 }}}

 While this *does* make it possible to override builtin methods,
 it also makes it impossible to write "class methods" that translate
 behaviors, since the presence or absence of the `:method` attribute on the
 sub is ignored.

 This behavior does not happen with non-builtin classes:
 {{{
 $ cat y.pir
 .sub main
     $P1 = newclass ['XYZ']
     $P0 = new ['XYZ']
     $P0.'foo'()
 .end

 .namespace ['XYZ']

 .sub 'foo'
     say 'foo'
 .end

 $ ./parrot y.pir
 Method 'foo' not found for invocant of class 'XYZ'
 current instr.: 'main' pc 11 (y.pir:4)
 $
 }}}

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