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


Given this code:

-----
use v6;

my role R {
    has $.thing;
}

multi sub trait_mod:<is> (Attribute:D $attr, :$whatever) {
    $attr does R;
    $attr.thing = 42;
}

class C {
    has $.val is whatever;
}
----

I get this error:

----
===SORRY!=== Error while compiling 
/home/autarch/projects/perl6/MetaX-Attribute-LazyBuild/./foo
Cannot modify an immutable Any
at /home/autarch/projects/perl6/MetaX-Attribute-LazyBuild/./foo:13
----

There are two problems here. One is that the line number is unhelpfully 
pointing at the line where I declare "has $.val is whatever" and the second is 
that I'm not being told what exact "immutable Any" can't be modified.

It'd be greatly preferable to get an error like "Cannot set immutable attribute 
thing on $attr at ...foo:9"

Reply via email to