AFAIU this error happens because s/// is implemented in terms of .subst-mutate 
(see commit https://github.com/rakudo/rakudo/commit/5a06ace5c5) and 
.subst-mutate currently only works for Str.

$ perl6 -e 'my $a = 43; $a.subst-mutate(3,2); say $a'
Cannot call 'subst-mutate'; none of these signatures match:
  in method subst-mutate at src/gen/m-CORE.setting:4669
  in block <unit> at -e:1

$ perl6 -e 'my $a = "43"; $a.subst-mutate(3,2); say $a'
42

I'm not sure if .subst-mutate is supposed to work with other types than Str -- 
and in case it is I don't know what should happen to the type of $a when 
.subst-mutate is applied. I played a bit and (naively) added a version of 
.subst-mutate (only locally, not in Rakudo) which accepts input of type 
Numeric, which is transformed to Str: 
https://gist.github.com/usev6/19baafe3390a274d87d0 But that approach looks a 
bit murky to me (e.g. calling .subst-mutate on a variable holding a Rat like 
2/5). And what about Arrays or other types?

Please note that it is possible to call .subst on an Array:

$ perl6 -e 'my @a = <43 21 7>; say @a.subst(3,2)'
42 21 7

Christian

Reply via email to