From 9a0a8507578c570661730c652a2ff084dd3b9fe9 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 3 Aug 2013 23:08:08 -0700 Subject: [PATCH] Revert "[perl #119043] Exempt shared hash key consts from ro" This reverts commit ba36554e02872e48d146177a57a9cfb154727fae. It turns out it reinstates bugs like this: $ perl -e 'for(1..10){for(__PACKAGE__){warn $_; $_++}}' main at -e line 1. maio at -e line 1. maip at -e line 1. maiq at -e line 1. mair at -e line 1. mais at -e line 1. mait at -e line 1. maiu at -e line 1. maiv at -e line 1. maiw at -e line 1. --- lib/overload.t | 7 ++++--- op.c | 4 +--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/overload.t b/lib/overload.t index e9ceb50..3af969b 100644 --- a/lib/overload.t +++ b/lib/overload.t @@ -1293,15 +1293,16 @@ foreach my $op (qw(<=> == != < <= > >=)) { } { - # Check readonliness of constants (brought up in bug #109744) - # For historical reasons, shared hash key scalars are exempt + # Check readonliness of constants, whether shared hash key + # scalars or no (brought up in bug #109744) BEGIN { overload::constant integer => sub { "main" }; } eval { ${\5} = 'whatever' }; like $@, qr/^Modification of a read-only value attempted at /, 'constant overloading makes read-only constants'; BEGIN { overload::constant integer => sub { __PACKAGE__ }; } eval { ${\5} = 'whatever' }; - is $@, "", 'except with shared hash key scalars'; + 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 55bfbf0..622236c 100644 --- a/op.c +++ b/op.c @@ -10569,9 +10569,7 @@ Perl_ck_svconst(pTHX_ OP *o) { PERL_ARGS_ASSERT_CK_SVCONST; PERL_UNUSED_CONTEXT; - /* For historical reasons, shared hash scalars are not made read-only. - */ - if (!SvIsCOW_shared_hash(cSVOPo->op_sv)) SvREADONLY_on(cSVOPo->op_sv); + SvREADONLY_on(cSVOPo->op_sv); return o; } -- 2.7.4