This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Revert "Revert "[perl #77496] tied gets scalars and globs confused""
authorFather Chrysostomos <sprout@cpan.org>
Fri, 13 May 2011 15:29:42 +0000 (08:29 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 11 Jun 2011 18:16:45 +0000 (11:16 -0700)
This reverts commit b029825916bf29623e00b45fa4226fab0d52d217.

pp_sys.c
t/op/tie.t

index 98c3cf2..a45a8c2 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -951,7 +951,7 @@ PP(pp_tied)
     const char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
                ? PERL_MAGIC_tied : PERL_MAGIC_tiedscalar;
 
-    if (isGV_with_GP(sv) && !(sv = MUTABLE_SV(GvIOp(sv))))
+    if (isGV_with_GP(sv) && !SvFAKE(sv) && !(sv = MUTABLE_SV(GvIOp(sv))))
        RETPUSHUNDEF;
 
     if ((mg = SvTIED_mg(sv, how))) {
index 8e17d16..44d9269 100644 (file)
@@ -1007,3 +1007,17 @@ tie $x, "";
 print "ok\n";
 EXPECT
 ok
+########
+
+# tied() should still work on tied scalars after glob assignment
+sub TIESCALAR {bless[]}
+sub FETCH {*foo}
+sub f::TIEHANDLE{bless[],f}
+tie *foo, "f";
+tie $rin, "";
+[$rin]; # call FETCH
+print ref tied $rin, "\n";
+print ref tied *$rin, "\n";
+EXPECT
+main
+f