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

Owner: Nobody
Requestors: chris [at] chrisdolan.net
Cc:
AdminCc:

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



Subject: [PATCH] 'does' fails with roles that have '::' in their names
Date: Thu, 6 Nov 2008 00:57:57 -0600
To: rakudobug [...] perl.org
From: Chris Dolan <chris [...] chrisdolan.net>
Download (untitled) / with headers
text/plain 1.1k
There are two bugs here. The attached patch fixes bug #2 but not bug #1. 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' Role ./perl6 -e 'role A::B { method foo { say "Foo"; } }; say A::B.WHAT' Module 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 {}; B.new.foo' Foo ./perl6 -e 'role A { method foo { say "Foo"; } }; class A::B::C does A {}; A::B::C.new.foo' Foo ./perl6 -e 'role A::B { method foo { say "Foo"; } }; class B does A::B {}; B.new.foo' Method 'foo' not found for invocant of class 'B' ./perl6 -e 'role A::B { method foo { say "Foo"; } }; class A::B::C does A::B {}; A::B::C.new.foo' Method 'foo' not found for invocant of class 'A;B;C' With the patch, I instead get: ./perl6 -e 'role A::B { method foo { say "Foo"; } }; class B does A::B {}; B.new.foo' does keyword can only be used with roles. which suggests that if the module/role bug were fixed, this code would work.
Download role.patch
text/plain 1.1k

Message body is not shown because sender requested not to inline it.

RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 981b
On Wed Nov 05 22:58:18 2008, chris@chrisdolan.net wrote: Show quoted text
> There are two bugs here. The attached patch fixes bug #2 but not bug > #1. > > 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' > Role > > ./perl6 -e 'role A::B { method foo { say "Foo"; } }; say A::B.WHAT' > Module >
Fixed. Show quoted text
> Bug #2) applying a role searches for the role in the wrong namespace. > > ./perl6 -e 'role A::B { method foo { say "Foo"; } }; class B does > A::B {}; B.new.foo' > Method 'foo' not found for invocant of class 'B' > > ./perl6 -e 'role A::B { method foo { say "Foo"; } }; class A::B::C > does A::B {}; A::B::C.new.foo' > Method 'foo' not found for invocant of class 'A;B;C' >
Applied your patch with minor simplifications to the code and with my fix to issue #1, it does indeed resolve this issue. Both in together as r33215, plus added a few tests. 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