Skip Menu |
Report information
Id: 60356
Status: resolved
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: Rakudo doesn't allow inheriting from classes with :: in the name
Date: Wed, 5 Nov 2008 22:42:31 +0100
To: rakudobug [...] perl.org
From: "Carl Mäsak" <cmasak [...] gmail.com>
Download (untitled) / with headers
text/plain 391b
<masak> rakudo: class A {}; class C is A {}; say "OH HAI" <p6eval> rakudo 32364: OUTPUT[OH HAI␤] <masak> rakudo: class A::B {}; class A::B::C is A::B {} <p6eval> rakudo 32364: OUTPUT[Attempt to inherit from non-existent parent class␤current instr.: 'die' pc 13394 (src/gen_builtins.pir:8255)␤] [...] <jnthn> masak: plz ticket that second one [...] * masak writes to rakudobug
Download (untitled) / with headers
text/plain 533b
On Wed Nov 05 13:42:51 2008, masak wrote: Show quoted text
> <masak> rakudo: class A {}; class C is A {}; say "OH HAI" > <p6eval> rakudo 32364: OUTPUT[OH HAI␤] > <masak> rakudo: class A::B {}; class A::B::C is A::B {} > <p6eval> rakudo 32364: OUTPUT[Attempt to inherit from non-existent parent > class␤current instr.: 'die' pc 13394
(src/gen_builtins.pir:8255)␤] Show quoted text
> [...] > <jnthn> masak: plz ticket that second one > [...] > * masak writes to rakudobug
Added (skipped) tests for that to t/spec/S12-class/inheritance.t in pugs r22889.
Download (untitled) / with headers
text/plain 1.2k
On Wed Nov 05 13:54:02 2008, moritz wrote: Show quoted text
> On Wed Nov 05 13:42:51 2008, masak wrote:
> > <masak> rakudo: class A {}; class C is A {}; say "OH HAI" > > <p6eval> rakudo 32364: OUTPUT[OH HAI␤] > > <masak> rakudo: class A::B {}; class A::B::C is A::B {} > > <p6eval> rakudo 32364: OUTPUT[Attempt to inherit from non-existent
parent Show quoted text
> > class␤current instr.: 'die' pc 13394
> (src/gen_builtins.pir:8255)␤]
> > [...] > > <jnthn> masak: plz ticket that second one > > [...] > > * masak writes to rakudobug
> > > Added (skipped) tests for that to t/spec/S12-class/inheritance.t in pugs > r22889.
I did ./perl6 --target=pir -e 'class A::B {}; class A::B::C is A::B {}' > 60356.pir ./perl6 -e 'use 60356' Then I hacked the PIR to get it to work. Here's the PIR diff that solves the problem. The next step is effecting that PIR change. --- 60356.pir~ 2008-11-05 21:36:54.000000000 -0600 +++ 60356.pir 2008-11-05 21:40:08.000000000 -0600 @@ -37,7 +37,7 @@ $P15."register"($P16, "Any" :named("parent")) $P17 = "!keyword_class"("A::B::C") store_lex "$def", $P17 - get_global $P18, "A::B" + get_global $P18, ["A"],"B" unless_null $P18, vivify_10 new $P18, "Undef" vivify_10:
Download (untitled) / with headers
text/plain 389b
... and here's a patch to Rakudo's actions.pm to implement the fix. I would be very happy if someone more experienced with NQP and PAST looked over the patch to see if there's a better way to do this. I haven't figured out the spec tests yet, so I only tested with the following one-liner: ./perl6 -e 'class A::B { method foo { say "Foo"; } }; class A::B::C is A::B {}; A::B::C.new.foo'
Download RT#60356.patch
text/plain 1.3k
Index: languages/perl6/src/parser/actions.pm =================================================================== --- languages/perl6/src/parser/actions.pm (revision 32369) +++ languages/perl6/src/parser/actions.pm (working copy) @@ -1453,16 +1453,22 @@ my $aux := $_<trait_auxiliary>; # Apply any "is" traits through MMD. if $aux<sym> eq 'is' { + my @identifier := Perl6::Compiler.parse_name(~$aux<name>); + my $name := @identifier.pop(); + my $superclass := PAST::Var.new( + :name($name), + :scope('package'), + :viviself('Undef') + ); + if +@identifier != 0 { + $superclass.namespace(@identifier); + } $package.push( PAST::Op.new( :pasttype('call'), :name('trait_auxiliary:is'), + $superclass, - PAST::Var.new( - :name(~$aux<name>), - :scope('package'), - :viviself('Undef') - ), PAST::Var.new( :name('$def'), :scope('lexical') )
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 664b
On Wed Nov 05 21:38:15 2008, chrisdolan wrote: Show quoted text
> ... and here's a patch to Rakudo's actions.pm to implement the fix. I > would be very happy if someone more experienced with NQP and PAST looked > over the patch to see if there's a better way to do this. >
Looks to be pretty much what I'd have done myself, for what that counts for. :-) Show quoted text
> I haven't figured out the spec tests yet, so I only tested with the > following one-liner: > > ./perl6 -e 'class A::B { method foo { say "Foo"; } }; class A::B::C is > A::B {}; A::B::C.new.foo'
It passed the spectests that moritz++ wrote too. So, patch applied in r32376, and the spectests are untodo'd. Thanks, Jonathan


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org