# New Ticket Created by  Martin Barth 
# Please include the string:  [perl #131707]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=131707 >


Hi there,

this is crossposed in the perl6-users mailing list. Since noone stopped 
me from assuming that this is a bug, i am going to open this now:


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 
a $!private member. (the files are in the end of the e-mail)


1) I am wondering why a role can all its private methods:

 > perl6 -I. -e 'use A; use B; my $b = B.new; $b.public-method()'
priv method


2) but can't write its private members:

 > perl6 -I. -e 'use A; use B; my $b = B.new; $b.set_private(A.new); $b.r'
No such private method '!!private' for invocant of type 'B'
   in method set_private at /home/martin/.workspace/p6/realerror/A.pm 
(A) line 24
   in block <unit> at -e line 1

WHEN! the set_private looks like this:

     method set_private(A $a) {
         self!private = $a;
     }


3) It seems to work (well, it gets a error a bit later in $b.r):

 > perl6 -I. -e 'use A; use B; my $b = B.new; $b.set_private(A.new); $b.r
'
P6opaque: no such attribute '$!private' in type B when trying to get a 
value
   in method s at /home/martin/.workspace/p6/realerror/A.pm (A) line 11
   in method s at /home/martin/.workspace/p6/realerror/A.pm (A) line 11
   in method r at /home/martin/.workspace/p6/realerror/A.pm (A) line 6
   in block <unit> at -e line 1

WHEN set_private looks like this:

     method set_private(A $a) {
         $!private = $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 
'!!private' for invocant of type 'B'" it was differently in 2016.11

Reply via email to