Pugs Diagnostics


This page is for documenting diagnostic messages emitted by Pugs, along with hints about what causes them and how to address them.

Can't modify constant item

Sometimes variables are read-only, such as when they are declared in a subroutine signature
or as a class attribute:

sub foo ($a) {
 $a ~~ s/b/c/; # Boom!
}
foo('b');

You can make a read/write copy of the variable through assignent ($b = $a), or by using is copy to declare that you want a read/write copy of the variable, or is rw to declare you want the variable being passed in to be modified by reference.