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



If you have a file that declares class Foo { ... } and then you define a method 
OUTSIDE of those curlies and then proceed to call it from another method 
declared inside of those curclies, you receive a confusing message that talks 
about attribute access and no hints that you're calling a method that's outside 
the class's definition. Attached is a sample class that can be called with 
`perl6 -I. -MFoo -e 'Foo.new.bar'` to reproduce the error. Which on my machine 
looks like this:


zoffix@ZofMain:/tmp/tmp.DPywLvk6la$ cat > Foo.pm6
class Foo {
    has @!bars = <foo bar ber mer>;
    method bar { self.mers; }
}

method mers {
    say @!bars;
}
zoffix@ZofMain:/tmp/tmp.DPywLvk6la$ perl6 -I. -MFoo -e 'Foo.new.bar'
===SORRY!=== Error while compiling /tmp/tmp.DPywLvk6la/Foo.pm6
Cannot understand @!bars in this context
at /tmp/tmp.DPywLvk6la/Foo.pm6:7
------>     say @!bars⏏;
===SORRY!=== Error while compiling /tmp/tmp.DPywLvk6la/Foo.pm6
Cannot understand @!bars in this context
at /tmp/tmp.DPywLvk6la/Foo.pm6:7
------>     say @!bars⏏;
zoffix@ZofMain:/tmp/tmp.DPywLvk6la$ perl6 -v
This is Rakudo version 2015.12-64-g6612747 built on MoarVM version 2015.12
implementing Perl 6.c.
zoffix@ZofMain:/tmp/tmp.DPywLvk6la$ 

Attachment: Foo.pm6
Description: Binary data

Reply via email to