This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make overloaded constants always read-only
authorFather Chrysostomos <sprout@cpan.org>
Wed, 3 Jul 2013 02:53:05 +0000 (19:53 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 26 Jul 2013 06:48:03 +0000 (23:48 -0700)
They were not read-only if the constant handler returned a shared
hash key scalar.

This was brought up in bug #109744.

lib/overload.t
op.c

index aa99cc2..3af969b 100644 (file)
@@ -1301,7 +1301,6 @@ foreach my $op (qw(<=> == != < <= > >=)) {
        'constant overloading makes read-only constants';
     BEGIN { overload::constant integer => sub { __PACKAGE__ }; }
     eval { ${\5} = 'whatever' };
-    local $::TODO = ' ';
     like $@, qr/^Modification of a read-only value attempted at /,
        '... even with shared hash key scalars';
 }
diff --git a/op.c b/op.c
index c136431..e308d08 100644 (file)
--- a/op.c
+++ b/op.c
@@ -10562,7 +10562,7 @@ Perl_ck_svconst(pTHX_ OP *o)
 {
     PERL_ARGS_ASSERT_CK_SVCONST;
     PERL_UNUSED_CONTEXT;
-    if (!SvIsCOW(cSVOPo->op_sv)) SvREADONLY_on(cSVOPo->op_sv);
+    SvREADONLY_on(cSVOPo->op_sv);
     return o;
 }