From: Father Chrysostomos (via RT) Date: Sun, 17 Jan 2010 22:32:24 +0000 (-0800) Subject: Deref ops ignore get-magic when SvROK(sv) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bb1bc619ea68d9703fbd3fe5bc65ae000f90151f;p=p5sagit%2Fp5-mst-13.2.git Deref ops ignore get-magic when SvROK(sv) This is just like bug 68192, except in this case it’s a different set of operators that have had this problem for much longer. --- diff --git a/pp.c b/pp.c index fa20914..d6e3132 100644 --- a/pp.c +++ b/pp.c @@ -139,6 +139,7 @@ PP(pp_rv2gv) { dVAR; dSP; dTOPss; + SvGETMAGIC(sv); if (SvROK(sv)) { wasref: tryAMAGICunDEREF(to_gv); @@ -156,11 +157,6 @@ PP(pp_rv2gv) } else { if (!isGV_with_GP(sv)) { - if (SvGMAGICAL(sv)) { - mg_get(sv); - if (SvROK(sv)) - goto wasref; - } if (!SvOK(sv) && sv != &PL_sv_undef) { /* If this is a 'my' scalar and flag is set then vivify * NI-S 1999/05/07 @@ -276,8 +272,8 @@ PP(pp_rv2sv) dVAR; dSP; dTOPss; GV *gv = NULL; + SvGETMAGIC(sv); if (SvROK(sv)) { - wasref: tryAMAGICunDEREF(to_sv); sv = SvRV(sv); @@ -295,11 +291,6 @@ PP(pp_rv2sv) gv = MUTABLE_GV(sv); if (!isGV_with_GP(gv)) { - if (SvGMAGICAL(sv)) { - mg_get(sv); - if (SvROK(sv)) - goto wasref; - } gv = Perl_softref2xv(aTHX_ sv, "a SCALAR", SVt_PV, &sp); if (!gv) RETURN; diff --git a/pp_hot.c b/pp_hot.c index ea24062..d5c13fe 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -820,8 +820,8 @@ PP(pp_rv2av) const bool is_pp_rv2av = PL_op->op_type == OP_RV2AV; const svtype type = is_pp_rv2av ? SVt_PVAV : SVt_PVHV; + SvGETMAGIC(sv); if (SvROK(sv)) { - wasref: tryAMAGICunDEREF_var(is_pp_rv2av ? to_av_amg : to_hv_amg); sv = SvRV(sv); @@ -858,11 +858,6 @@ PP(pp_rv2av) GV *gv; if (!isGV_with_GP(sv)) { - if (SvGMAGICAL(sv)) { - mg_get(sv); - if (SvROK(sv)) - goto wasref; - } gv = Perl_softref2xv(aTHX_ sv, is_pp_rv2av ? an_array : a_hash, type, &sp); if (!gv) diff --git a/t/op/tie.t b/t/op/tie.t index 5db6cfb..281c0d9 100644 --- a/t/op/tie.t +++ b/t/op/tie.t @@ -840,6 +840,10 @@ fetching... <=> 1 { package overloaded; use overload + '*{}' => sub { print '*{}'; \*100 }, + '@{}' => sub { print '@{}'; \@100 }, + '%{}' => sub { print '%{}'; \%100 }, + '${}' => sub { print '${}'; \$100 }, map { my $op = $_; $_ => sub { print "$op"; 100 } @@ -868,6 +872,10 @@ $ghew=undef; $ghew<=1; print "\n"; $ghew=undef; $ghew >=1; print "\n"; $ghew=undef; $ghew != 1; print "\n"; $ghew=undef; $ghew<=>1; print "\n"; +$ghew=\*shrext; *$ghew; print "\n"; +$ghew=\@spled; @$ghew; print "\n"; +$ghew=\%frit; %$ghew; print "\n"; +$ghew=\$drile; $$ghew; print "\n"; EXPECT fetching... + fetching... ** @@ -885,3 +893,7 @@ fetching... <= fetching... >= fetching... != fetching... <=> +fetching... *{} +fetching... @{} +fetching... %{} +fetching... ${}