Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rakudo doesn't allow inheriting from classes with :: in the name #388

Closed
p6rt opened this issue Nov 5, 2008 · 8 comments
Closed

Rakudo doesn't allow inheriting from classes with :: in the name #388

p6rt opened this issue Nov 5, 2008 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Nov 5, 2008

Migrated from rt.perl.org#60356 (status was 'resolved')

Searchable as RT60356$

@p6rt
Copy link
Author

p6rt commented Nov 5, 2008

From @masak

<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

@p6rt
Copy link
Author

p6rt commented Nov 5, 2008

From @moritz

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
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.

@p6rt
Copy link
Author

p6rt commented Nov 5, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Nov 6, 2008

From @chrisdolan

On Wed Nov 05 13​:54​:02 2008, moritz wrote​:

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
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.

Inline Patch
--- 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:

@p6rt
Copy link
Author

p6rt commented Nov 6, 2008

From @chrisdolan

... 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'

@p6rt
Copy link
Author

p6rt commented Nov 6, 2008

From @chrisdolan

RT#60356.patch
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')
                     )

@p6rt
Copy link
Author

p6rt commented Nov 6, 2008

From @jnthn

On Wed Nov 05 21​:38​:15 2008, chrisdolan wrote​:

... 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. :-)

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

@p6rt
Copy link
Author

p6rt commented Nov 6, 2008

@jnthn - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Nov 6, 2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant