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
'does' fails with roles that have '::' in their names #390
Comments
From @chrisdolanThere are two bugs here. The attached patch fixes bug #2 but not bug Bug #1) "role A::B" is not interpreted as a role, but just as a module. ./perl6 -e 'role A { method foo { say "Foo"; } }; say A.WHAT' ./perl6 -e 'role A::B { method foo { say "Foo"; } }; say A::B.WHAT' Bug #2) applying a role searches for the role in the wrong namespace. ./perl6 -e 'role A { method foo { say "Foo"; } }; class B does A ./perl6 -e 'role A { method foo { say "Foo"; } }; class A::B::C ./perl6 -e 'role A::B { method foo { say "Foo"; } }; class B does ./perl6 -e 'role A::B { method foo { say "Foo"; } }; class A::B::C With the patch, I instead get: ./perl6 -e 'role A::B { method foo { say "Foo"; } }; class B does which suggests that if the module/role bug were fixed, this code |
From @chrisdolanrole.patchIndex: languages/perl6/src/parser/actions.pm
===================================================================
--- languages/perl6/src/parser/actions.pm (revision 32369)
+++ languages/perl6/src/parser/actions.pm (working copy)
@@ -1471,6 +1477,15 @@
}
elsif $aux<sym> eq 'does' {
# Role.
+ my @identifier := Perl6::Compiler.parse_name(~$aux<name>);
+ my $name := @identifier.pop();
+ my $superrole := PAST::Var.new(
+ :name($name),
+ :scope('package'),
+ );
+ if +@identifier != 0 {
+ $superrole.namespace(@identifier);
+ }
$package.push(
PAST::Op.new(
:pasttype('call'),
@@ -1479,10 +1494,7 @@
:name('$def'),
:scope('lexical')
),
- PAST::Var.new(
- :name(~$aux<name>),
- :scope('package')
- )
+ $superrole
)
);
}
|
From @jnthnOn Wed Nov 05 22:58:18 2008, chris@chrisdolan.net wrote:
Fixed.
Applied your patch with minor simplifications to the code and with my Both in together as r33215, plus added a few tests. Thanks! Jonathan |
The RT System itself - Status changed from 'new' to 'open' |
@jnthn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#60366 (status was 'resolved')
Searchable as RT60366$
The text was updated successfully, but these errors were encountered: