summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-01-03 22:44:49 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-01-03 22:44:49 -0800
commit407287f90891c4292ac8268e6566164f3992e28e (patch)
tree9b3942ea780fa36d2b462605d8fed73df9987d3e
parent9f7d1e40385f2b6a774be929b592fac0dea1458e (diff)
downloadperl-407287f90891c4292ac8268e6566164f3992e28e.tar.gz
[perl #105912] local $_ should not FETCH
This commit finishes the work of 658a9f3 by skipping FETCH as well as STORE during local($_).
-rw-r--r--mg.c2
-rw-r--r--t/op/local.t7
2 files changed, 5 insertions, 4 deletions
diff --git a/mg.c b/mg.c
index 31330dd903..5e11ec4e42 100644
--- a/mg.c
+++ b/mg.c
@@ -182,6 +182,8 @@ Perl_mg_get(pTHX_ SV *sv)
PERL_ARGS_ASSERT_MG_GET;
+ if (PL_localizing == 1 && sv == DEFSV) return 0;
+
save_magic(mgs_ix, sv);
/* We must call svt_get(sv, mg) for each valid entry in the linked
diff --git a/t/op/local.t b/t/op/local.t
index d7a29756df..d70feb7b07 100644
--- a/t/op/local.t
+++ b/t/op/local.t
@@ -618,8 +618,6 @@ while (/(o.+?),/gc) {
"Chop" => sub { chop }, 0,
"Filetest" => sub { -x }, 0,
"Assignment" => sub { $_ = "Bad" }, 0,
- # XXX whether next one should fail is debatable
- "Local \$_" => sub { local $_ = 'ok?'; print }, 0,
"for local" => sub { for("#ok?\n"){ print } }, 1,
);
while ( ($name, $code, $ok) = splice(@tests, 0, 3) ) {
@@ -649,10 +647,10 @@ eval { for ($1) { local $_ = 1 } };
is($@, "");
{
- my $STORE = 0;
+ my $STORE = my $FETCH = 0;
package TieHash;
sub TIEHASH { bless $_[1], $_[0] }
- sub FETCH { 42 }
+ sub FETCH { ++$FETCH; 42 }
sub STORE { ++$STORE }
package main;
@@ -660,6 +658,7 @@ is($@, "");
eval { for ($hash{key}) {local $_ = 2} };
is($STORE, 0);
+ is($FETCH, 0);
}
# The s/// adds 'g' magic to $_, but it should remain non-readonly