In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/b99dfd93f5b9b7f9cde5b9fa259b66c2bc08bcf1?hp=6dfc73ea459d59204dc98d8ed6c7dddf96b40d2a>

- Log -----------------------------------------------------------------
commit b99dfd93f5b9b7f9cde5b9fa259b66c2bc08bcf1
Author: David Mitchell <[email protected]>
Date:   Thu Apr 9 10:50:51 2015 +0100

    keep FOO read-only in 'FOO'->f()
    
    RT #123619
    
    The new method code (d648ffcb179) was replacing the const SV attached to
    the const op with a shared-string version, but was failing to make the new
    SV read-only.
-----------------------------------------------------------------------

Summary of changes:
 op.c          |  2 ++
 t/op/method.t | 10 +++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/op.c b/op.c
index ad0b0b0..c136a1a 100644
--- a/op.c
+++ b/op.c
@@ -11911,6 +11911,8 @@ Perl_ck_subr(pTHX_ OP *o)
                                     ? -(SSize_t)len : (SSize_t)len,
                         0
                    );
+                    if (SvREADONLY(*const_class))
+                        SvREADONLY_on(shared);
                    SvREFCNT_dec(*const_class);
                    *const_class = shared;
                }
diff --git a/t/op/method.t b/t/op/method.t
index 4583d50..1171f4a 100644
--- a/t/op/method.t
+++ b/t/op/method.t
@@ -13,7 +13,7 @@ BEGIN {
 use strict;
 no warnings 'once';
 
-plan(tests => 146);
+plan(tests => 147);
 
 @A::ISA = 'B';
 @B::ISA = 'C';
@@ -649,6 +649,14 @@ SKIP: {
        'restoring the stash returns to a method');
 }
 
+# RT #123619 constant class name should be read-only
+
+{
+    sub RT123619::f { chop $_[0] }
+    eval { 'RT123619'->f(); };
+    like ($@, qr/Modification of a read-only value attempted/, 'RT #123619');
+}
+
 __END__
 #FF9900
 #F78C08

--
Perl5 Master Repository

Reply via email to