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
Private Methods/Attributes in roles do not work as expected #6379
Comments
From martin@senfdax.deHi there, this is crossposed in the perl6-users mailing list. Since noone stopped Assuming those two files A.pm and B.pm. The file A.pm contains a class A and a role R with a private-method and 1) I am wondering why a role can all its private methods:
2) but can't write its private members:
WHEN! the set_private looks like this: method set_private(A $a) { 3) It seems to work (well, it gets a error a bit later in $b.r):
WHEN set_private looks like this: method set_private(A $a) { But method !s seems to be broken now. I dont get why :( i would expect this to work. :-( In addition I think the error message is broken: "No such private method |
From @zoffixznetOn Wed, 05 Jul 2017 09:09:48 -0700, martin@senfdax.de wrote:
Hi, what's the full code in A.pm and B.pm files? |
The RT System itself - Status changed from 'new' to 'open' |
From @zoffixznet
role R { method r { method !s { method !private-method { method public-method { method set_private(A $a) { class A does R {
class B does R { |
From martin@senfdax.de
role R { method r { method !s { method !private-method { method public-method { method set_private(A $a) { class A does R {
class B does R { Am 06.07.2017 um 15:35 schrieb Zoffix Znet via RT:
|
I've golfed it down to : role R {
has $!private;
method !s {
$!private if $!private;
}
method !private-method {
say "priv method";
}
method public-method {
self!private-method;
}
method set_private($a) {
$!private = $a;
}
}
class B does R {
method b { self!s }
}
my $b = B.new();
$b.public-method();
$b.set_private("foo");
say $b.b; and then the error disappears. The problem seems to lay in the strange construct |
No need to golf it down. |
I'm starting to think this is a case of an LTA error more than any other thing. The problem is that, instead of just saying "Hey, A's method are private to this object, which is B" it's kind of mixing A and B. It should probably say "no such attribute on type A" (because it's private to B). If that's the case I can probably fix it. |
Maybe related to rakudo/rakudo#4127 |
... And I leave the rabbit hole trying to look up where nqp::getattr is defined. I think it must be there, since it's not a Rakudo exception, but a NQP runtime exception, but that's way above my pay grade. Should be easy if anyone is familiar with that, I guess. |
Migrated from rt.perl.org#131707 (status was 'open')
Searchable as RT131707$
The text was updated successfully, but these errors were encountered: