This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #119043] Exempt shared hash key consts from ro
[perl5.git] / op.c
diff --git a/op.c b/op.c
index 7576509..9ae0812 100644 (file)
--- a/op.c
+++ b/op.c
@@ -10568,7 +10568,9 @@ Perl_ck_svconst(pTHX_ OP *o)
 {
     PERL_ARGS_ASSERT_CK_SVCONST;
     PERL_UNUSED_CONTEXT;
 {
     PERL_ARGS_ASSERT_CK_SVCONST;
     PERL_UNUSED_CONTEXT;
-    SvREADONLY_on(cSVOPo->op_sv);
+    /* For historical reasons, shared hash scalars are not made read-only.
+     */
+    if (!SvIsCOW_shared_hash(cSVOPo->op_sv)) SvREADONLY_on(cSVOPo->op_sv);
     return o;
 }
 
     return o;
 }