summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-01-13 09:32:20 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-01-13 21:24:54 -0800
commit213084e431373aec68f094fabf7c87419d9c7688 (patch)
tree1061abfa3b658a625cc179807c861e0a493d111c
parentffdb8bcde21504a3efe208b4d47bea445e7e23fd (diff)
downloadperl-213084e431373aec68f094fabf7c87419d9c7688.tar.gz
defined *{"+"} should not stop %+ from working
The same applies to %-. This is something I broke when merging is_magical_gv with gv_fetchpvn_flags. gv_fetchpvn_flags must make sure its *+ glob is present in the symbol table when it loads Tie::Hash::NamedCapture. If it adds it afterwards it will clobber another *+ that Tie::Hash::NamedCapture has autovivi- fied and tied in the mean time.
-rw-r--r--gv.c4
-rw-r--r--t/op/magic.t20
2 files changed, 23 insertions, 1 deletions
diff --git a/gv.c b/gv.c
index 9da6c1a675..af8f289cc6 100644
--- a/gv.c
+++ b/gv.c
@@ -1913,7 +1913,11 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
SvREADONLY_on(av);
if (sv_type == SVt_PVHV || sv_type == SVt_PVGV)
+ {
+ if (addmg) (void)hv_store(stash,name,len,(SV *)gv,0);
+ addmg = 0;
require_tie_mod(gv, name, newSVpvs("Tie::Hash::NamedCapture"), "TIEHASH", 0);
+ }
break;
}
diff --git a/t/op/magic.t b/t/op/magic.t
index 494847f7f1..9b43069a00 100644
--- a/t/op/magic.t
+++ b/t/op/magic.t
@@ -5,7 +5,7 @@ BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require './test.pl';
- plan (tests => 154);
+ plan (tests => 156);
}
# Test that defined() returns true for magic variables created on the fly,
@@ -545,6 +545,24 @@ foreach my $sig (qw(__DIE__ _BOGUS_HOOK KILL THIRSTY)) {
}
+# %+ %-
+SKIP: {
+ skip_if_miniperl("No XS in miniperl", 3);
+ # Make sure defined(*{"+"}) before %+ does not stop %+ from working
+ is
+ runperl(
+ prog => 'BEGIN { defined *{q-+-} } print qq-ok\n- if tied %+',
+ ),
+ "ok\n",
+ 'defined *{"+"} does not stop %+ from working';
+ is
+ runperl(
+ prog => 'BEGIN { defined *{q=-=} } print qq-ok\n- if tied %-',
+ ),
+ "ok\n",
+ 'defined *{"-"} does not stop %- from working';
+}
+
SKIP: {
skip_if_miniperl("No XS in miniperl", 3);