From 0ad6fa3530955d1b19193ff491530a86d99191a1 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Wed, 24 Jul 2013 08:39:01 -0700 Subject: [PATCH] Stop op freeing from interfering with sub(){42} mutability MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The problem is that when an OP_CONST is freed, it calls pad_swipe, which clears the PADTMP flag when removing the SV from the pad. Since PADTMP no longer necessarily means ‘in a pad’, we shouldn’t turn this flag off. --- pad.c | 2 -- t/op/sub.t | 8 +++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pad.c b/pad.c index 76d8aa4..0bf65cd 100644 --- a/pad.c +++ b/pad.c @@ -1638,8 +1638,6 @@ Perl_pad_swipe(pTHX_ PADOFFSET po, bool refadjust) "Pad 0x%"UVxf"[0x%"UVxf"] swipe: %ld\n", PTR2UV(PL_comppad), PTR2UV(PL_curpad), (long)po)); - if (PL_curpad[po] && !SvPADMY(PL_curpad[po])) - SvPADTMP_off(PL_curpad[po]); if (refadjust) SvREFCNT_dec(PL_curpad[po]); diff --git a/t/op/sub.t b/t/op/sub.t index 53eae4a..fc04ac8 100644 --- a/t/op/sub.t +++ b/t/op/sub.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan( tests => 26 ); +plan( tests => 27 ); sub empty_sub {} @@ -140,6 +140,12 @@ eval { ${\not_constantm}++ }; is $@, "", 'my sub (){42} returns a mutable value'; eval { ${\not_constantmr}++ }; is $@, "", 'my sub (){ return 42 } returns a mutable value'; +is eval { + sub Crunchy () { 1 } + sub Munchy { $_[0] = 2 } + eval "Crunchy"; # test that freeing this op does not turn off PADTMP + Munchy(Crunchy); +} || $@, 2, 'freeing ops does not make sub(){42} immutable'; # [perl #79908] { -- 1.8.3.1