summaryrefslogtreecommitdiff
path: root/t/op
diff options
context:
space:
mode:
authorLubomir Rintel (GoodData) <lubo.rintel@gooddata.com>2010-04-22 18:19:23 +0200
committerRafael Garcia-Suarez <rgs@consttype.org>2010-04-26 11:52:48 +0200
commitb9e00b79e4947c49d5520633f9efd2a8e39ec14f (patch)
treef870176dcfc5732189e4cca4c216ca4cb4600254 /t/op
parent01146bad274273e459645fb4cce5aeac95999d64 (diff)
downloadperl-b9e00b79e4947c49d5520633f9efd2a8e39ec14f.tar.gz
Globs that are in symbol table can be un-globbed
If a symbol table entry is undefined when a glob is assigned into it, it gets a FAKE flag which makes it possible to be downgraded when non-glob is subsequently assigned into it. It doesn't really matter, until we decide to localize it -- it wouldn't be possible to restore its GP upon context return if it changed type, therefore we must not do that. This patch turns off FAKE flag when localizing a GV and restores it when the context is left. A test case is included.
Diffstat (limited to 't/op')
-rw-r--r--t/op/gv.t11
1 files changed, 10 insertions, 1 deletions
diff --git a/t/op/gv.t b/t/op/gv.t
index 382e3f0157..f3511e353b 100644
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -12,7 +12,7 @@ BEGIN {
use warnings;
require './test.pl';
-plan( tests => 188 );
+plan( tests => 191 );
# type coersion on assignment
$foo = 'foo';
@@ -614,6 +614,15 @@ ok(exists($RT72740a::{s4}), "RT72740a::s4 exists");
is(RT72740a::s1(), "RT72740b::s2", "RT72740::s1 parsed correctly");
is(RT72740a::s3(), "RT72740b::s4", "RT72740::s3 parsed correctly");
+# [perl #71686] Globs that are in symbol table can be un-globbed
+$sym = undef;
+$::{fake} = *sym;
+is (eval 'local *::fake = \"chuck"; $fake', 'chuck',
+ "Localized glob didn't coerce into a RV");
+is ($@, '', "Can localize FAKE glob that's present in stash");
+is (scalar $::{fake}, "*main::sym",
+ "Localized FAKE glob's value was correctly restored");
+
__END__
Perl
Rules