# New Ticket Created by Edwin Steiner
# Please include the string: [perl #115212]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=115212 >
When a role requires a method to be implented, rakudo does not consider
accessor methods that implement the required method.
Also the error message is LTA as it would be nice to know *which* role requires
the method.
Example:
$ cat t2.pl
role Wanter {
method foo { ... }
method bar { self.foo + 1 }
}
class Giver does Wanter {
has $.foo;
# This line should not be necessary: method foo { $!foo }
}
say Giver.new(:foo(41)).bar;
$ ./perl6 t2.pl
===SORRY!===
Method 'foo' must be implemented by Giver because it is required by a role
$ ./perl6 --version
This is perl6 version 2012.09.1-7-gfb11f13 built on parrot 4.4.0 revision
RELEASE_4_4_0
IRC log about this topic:
http://irclog.perlgeek.de/perl6/2012-10-09#i_6047393
20:52 _edwin when I change to "role FPS" I get an error that ExplicitFPS
does not implement the method coeffs
20:53 it seems the implicit accessor method does not count towards
the role
20:53 colomon _edwin: you can easily explicitly define it, obviously, but I
am surprised, I admit.
20:53 _edwin is it a bug or a feature? :}
20:53 jnthn Well, things at composition time have to happen in some order.
20:54 colomon _edwin: I think you need jnthn for that question. :)
20:54 jnthn At the moment roles are composed *then* we compose attributes.
20:55 iirc, it has to be that way because roles can contribute
attributes that need accessors generating too
20:55 Is the issue that the role has a required method?
20:55 _edwin yes
20:55 jnthn Yeah...
20:55 I don't think we can fix that by swapping around the order
compose does things.
20:55 But I agree it's icky
20:56 _edwin and the derived class just "has @.coeffs" and not "method
coeffs { @.coeffs }"
20:56 jnthn Yeah
20:56 I suspect it's possible for the role applier to give back a
list of things that are required
20:56 But not complain about them immediately
20:56 And then we check if they're there later
20:58 jnthn _edwin: I think you want method coeffs { @!coeffs }
20:58 _edwin: I think the requirement/accessor thing should really be
fixed. Please file a ticket.