summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-08-19 23:17:08 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-08-20 12:50:00 -0700
commit3a6ce63afe9bfc9bf645e0c127824d8426a7ee67 (patch)
tree6a994506662ea1964fea6cddf3afc61f994ca276 /op.c
parent25451ceff7e8f05c501ecc72a1b3536005f391f7 (diff)
downloadperl-3a6ce63afe9bfc9bf645e0c127824d8426a7ee67.tar.gz
Fix skip logic in pad_tidy and cv_clone
Commit 325e1816dc changed the logic for determining whether a pad entry is to be treated like a constant; i.e., shared between recursion levels and sub clones. According the old logic, a pad entry must be shared if it is marked READONLY or is a shared hash key scalar. According to the new logic, the entry must be shared if the pad name has a zero-length PV (i.e., &PL_sv_no). Two pieces of code were still following the old logic. Changing them fixes this old bug: my $close_over_me; sub { () = $close_over_me; open my $fh, "/dev/null"; print "$$fh\n" }->(); __END__ Output: *main:: The name attached to the implicit rv2gv op in open() was not being copied by sub clones. The previous commit is also part of the fix. In the tests, I tested the combination of sub cloning and recursion, since it seemed like a good idea (and also as a result of copying and pasting :-). S_pmtrans was still relying on the old logic, so it gets changed, too.
Diffstat (limited to 'op.c')
-rw-r--r--op.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/op.c b/op.c
index 44d2f203fb..c5964eb88f 100644
--- a/op.c
+++ b/op.c
@@ -4268,7 +4268,7 @@ S_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
swash = MUTABLE_SV(swash_init("utf8", "", listsv, bits, none));
#ifdef USE_ITHREADS
- cPADOPo->op_padix = pad_alloc(OP_TRANS, SVs_PADTMP);
+ cPADOPo->op_padix = pad_alloc(OP_TRANS, SVf_READONLY);
SvREFCNT_dec(PAD_SVl(cPADOPo->op_padix));
PAD_SETSV(cPADOPo->op_padix, swash);
SvPADTMP_on(swash);