From 8752206e276cffe588c0932b5a9f2331640e8447 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sun, 24 Oct 2010 18:14:47 -0700 Subject: [PATCH] [perl #77496] tied gets scalars and globs confused Make pp_tied use the SvFAKE flag to distinguish between tied scalars and tied handles. This is now possible as of change 2acc3314. This fixes the problem of tied($scalar) ignoring the tie if the last thing returned or assigned happened to be a glob. --- pp_sys.c | 2 +- t/op/tie.t | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pp_sys.c b/pp_sys.c index 78b635f..f47395b 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -941,7 +941,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))) { diff --git a/t/op/tie.t b/t/op/tie.t index 6e52a6e..a9fb89e 100644 --- a/t/op/tie.t +++ b/t/op/tie.t @@ -939,3 +939,17 @@ sub IO::File::TIEARRAY { fileno FOO; tie @a, "FOO" EXPECT Can't locate object method "TIEARRAY" via package "FOO" at - line 5. +######## + +# 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 -- 2.7.4