Skip Menu |
Report information
Id: 127110
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: autarch <autarch [at] urth.org>
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: Error message for setting ro attribute inside a trait_mod:<is> sub is LTA
Download (untitled) / with headers
text/plain 766b
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"
Download (untitled) / with headers
text/plain 224b
mst++ pointed out that if the problem is with the _user_ of a trait, then reporting the error at the line where the trait is used does make sense. This argues for reporting both lines and/or just including a full call stack.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org