This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Read-only COWs should not be exempt from s/// croaking
authorFather Chrysostomos <sprout@cpan.org>
Sat, 10 Aug 2013 01:36:39 +0000 (18:36 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 11 Aug 2013 14:41:26 +0000 (07:41 -0700)
commit958851d8f0bcfcbfc1dd2ad9e869430180974b69
tree964f0126697b91e37ee0750f4a01ca19dd8b2b30
parent9ff3e6d8e1976c0d05c130c992864d16ab35ce39
Read-only COWs should not be exempt from s/// croaking

$  ./miniperl -Ilib -e 'for(__PACKAGE__) { s/a/a/ }'
Modification of a read-only value attempted at -e line 1.
$  ./miniperl -Ilib -e 'for(__PACKAGE__) { s/b/b/ }'
$  ./miniperl -Ilib -e 'for("main") { s/a/a/ }'
Modification of a read-only value attempted at -e line 1.
$  ./miniperl -Ilib -e 'for("main") { s/b/b/ }'
Modification of a read-only value attempted at -e line 1.

When I pass the constant "main" to s///, it croaks whether the regular
expression matches or not.

When I pass __PACKAGE__, which has the same content and is also read-
only, it only croaks when the pattern matches.

This commit removes some logic that is left over from when
READONLY+FAKE meant copy-on-write.  Read-only does mean read-only now,
so copy-on-write scalars should not be exempt from read-only checks.
pp_hot.c
t/re/subst.t