This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Pure Perl lvalue subs can't return temps, even if they are magical. This holds back...
authorEric Brine <ikegami@adaelis.com>
Tue, 13 Jul 2010 19:56:38 +0000 (12:56 -0700)
committerRafael Garcia-Suarez <rgs@consttype.org>
Fri, 13 Aug 2010 11:36:29 +0000 (13:36 +0200)
This commit allows PP lvalue subs to return temps with set magic
and removes TODO from tests.

ext/XS-APItest/t/temp_lv_sub.t
pp_hot.c

index bfcacd6..d0c51fd 100644 (file)
@@ -27,7 +27,6 @@ sub make_temp_mg_lv :lvalue {  XS::APItest::TempLv::make_temp_mg_lv($_[0]); }
 }
 
 {
-    local $TODO = "PP lvalue sub can't return magical temp";
     my $x = "{}";
     eval { make_temp_mg_lv($x) = "b"; };
     is($@, '',    'temp mg lv from pp exception check');
index 2b67f4f..e1f0fc9 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2610,13 +2610,13 @@ PP(pp_leavesublv)
            MARK = newsp + 1;
            EXTEND_MORTAL(1);
            if (MARK == SP) {
-               /* Temporaries are bad unless they happen to be elements
-                * of a tied hash or array */
+               /* Temporaries are bad unless they happen to have set magic
+                * attached, such as the elements of a tied hash or array */
                if ((SvFLAGS(TOPs) & (SVs_TEMP | SVs_PADTMP) ||
                     (SvFLAGS(TOPs) & (SVf_READONLY | SVf_FAKE))
                       == SVf_READONLY
                    ) &&
-                   !(SvRMAGICAL(TOPs) && mg_find(TOPs, PERL_MAGIC_tiedelem))) {
+                   !SvSMAGICAL(TOPs)) {
                    LEAVE;
                    cxstack_ix--;
                    POPSUB(cx,sv);