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

Owner: Nobody
Requestors: rob [at] hoelz.ro
Cc:
AdminCc:

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



Subject: LTA error message when you try to modify an ro parameter
Download (untitled) / with headers
text/plain 881b
Simliar to https://rt.perl.org/Ticket/Display.html?id=125531, but that ticket appears for more subtle reasons ($/ being modified as the result of operations like ~~). If I try to modify an ro parameter, or the parameter to a for loop (which, when using ->, I guess is another sort of ro parameter), I get one of the two error messages: sub foo(Str $str) { $str ~= 'another'; # Cannot assign to an immutable value $str .= substr(0, 3); # Cannot modify an immutable Str } I've also seen "Cannot assign to a readonly variable or a value". While the error message makes sense, it may be nice to... - Indicate the variable being assigned to, if it is indeed a variable. - (In the case of the linked ticket mentioning $/) Indicate the operation responsible for the writing - (Other than for $/) Suggest is copy or <-> if that is what the user means.
On 2015-07-10 05:46:10, rob@hoelz.ro wrote: Show quoted text
> Simliar to https://rt.perl.org/Ticket/Display.html?id=125531, but that > ticket appears for more subtle reasons ($/ being modified as the > result of operations like ~~). > > If I try to modify an ro parameter, or the parameter to a for loop > (which, when using ->, I guess is another sort of ro parameter), I get > one of the two error messages: > > sub foo(Str $str) { > $str ~= 'another'; # Cannot assign to an immutable value > $str .= substr(0, 3); # Cannot modify an immutable Str > } > > I've also seen "Cannot assign to a readonly variable or a value". > > While the error message makes sense, it may be nice to... > > - Indicate the variable being assigned to, if it is indeed a variable. > - (In the case of the linked ticket mentioning $/) Indicate the > operation responsible for the writing > - (Other than for $/) Suggest is copy or <-> if that is what the user > means.
"Cannot assign to a readonly variable or a value" occurs with for loop parameters.


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