summaryrefslogtreecommitdiff
path: root/t/op
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2010-07-10 15:09:51 -0400
committerRafael Garcia-Suarez <rgs@consttype.org>2010-07-26 10:16:55 +0200
commit0fe688f528b0e1b5bef6fb30d5e45316430e8a41 (patch)
treea38f5eb47badce81268c3c57df36562d8ac90c91 /t/op
parent1eb3f3ad74c5c8cb35d027485b9938eb0a64db40 (diff)
downloadperl-0fe688f528b0e1b5bef6fb30d5e45316430e8a41.tar.gz
Fix for RT#1804: Anonymous glob breaks when assigned through
The problem here is that globs are scalars and the = operator can only distinguish between scalar and glob assignments by the flags on the glob. It only sees the return value of *{}, not the *{} itself. We can fix this by having the pp_sassign look for a rv2gv (*{}) on its LHS, to decide what type of assignment to do.
Diffstat (limited to 't/op')
-rw-r--r--t/op/gv.t13
1 files changed, 12 insertions, 1 deletions
diff --git a/t/op/gv.t b/t/op/gv.t
index f3511e353b..13da980365 100644
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -12,7 +12,7 @@ BEGIN {
use warnings;
require './test.pl';
-plan( tests => 191 );
+plan( tests => 192 );
# type coersion on assignment
$foo = 'foo';
@@ -623,6 +623,17 @@ is ($@, '', "Can localize FAKE glob that's present in stash");
is (scalar $::{fake}, "*main::sym",
"Localized FAKE glob's value was correctly restored");
+# [perl #1804] *$x assignment when $x is a copy of another glob
+{
+ no warnings 'once';
+ my $x = *_random::glob_that_is_not_used_elsewhere;
+ *$x = sub{};
+ is(
+ "$x", '*_random::glob_that_is_not_used_elsewhere',
+ '[perl #1804] *$x assignment when $x is FAKE',
+ );
+}
+
__END__
Perl
Rules