In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/f71f472facac5b530b24a8ff8a79a629776411e0?hp=0fe688f528b0e1b5bef6fb30d5e45316430e8a41>

- Log -----------------------------------------------------------------
commit f71f472facac5b530b24a8ff8a79a629776411e0
Author: Father Chrysostomos <[email protected]>
Date:   Mon Jul 26 10:52:48 2010 +0200

    [perl #75656] lvalue subs don't copy on write
    
    The attached patch teaches pp_leavesublv about kine.
    
    For the record, a binary search points its digit at:
    
    From: Nicholas Clark <[email protected]>
    Date: Mon, 6 Jun 2005 09:08:45 +0000 (+0000)
    Subject: Shared hash key scalars can be safely copied as shared hash key 
scalars
    
    Shared hash key scalars can be safely copied as shared hash key scalars all 
the time.
-----------------------------------------------------------------------

Summary of changes:
 pp_hot.c        |    5 ++++-
 t/op/sub_lval.t |    7 ++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/pp_hot.c b/pp_hot.c
index bd0f909..d66ddde 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2611,7 +2611,10 @@ PP(pp_leavesublv)
            if (MARK == SP) {
                /* Temporaries are bad unless they happen to be elements
                 * of a tied hash or array */
-               if (SvFLAGS(TOPs) & (SVs_TEMP | SVs_PADTMP | SVf_READONLY) &&
+               if ((SvFLAGS(TOPs) & (SVs_TEMP | SVs_PADTMP) ||
+                    (SvFLAGS(TOPs) & (SVf_READONLY | SVf_FAKE))
+                      == SVf_READONLY
+                   ) &&
                    !(SvRMAGICAL(TOPs) && mg_find(TOPs, PERL_MAGIC_tiedelem))) {
                    LEAVE;
                    cxstack_ix--;
diff --git a/t/op/sub_lval.t b/t/op/sub_lval.t
index c20ffac..f754782 100644
--- a/t/op/sub_lval.t
+++ b/t/op/sub_lval.t
@@ -3,7 +3,7 @@ BEGIN {
     @INC = '../lib';
     require './test.pl';
 }
-plan tests=>71;
+plan tests=>73;
 
 sub a : lvalue { my $a = 34; ${\(bless \$a)} }  # Return a temporary
 sub b : lvalue { ${\shift} }
@@ -570,3 +570,8 @@ Execution of - aborted due to compilation errors.
     lval_decl = 5;
     is($x, 5, "subroutine declared with lvalue before definition retains 
lvalue. [perl #68758]");
 }
+
+sub fleen : lvalue { $pnare }
+$pnare = __PACKAGE__;
+ok eval { fleen = 1 }, "lvalues can return COWs (CATTLE?) [perl #75656]";\
+is $pnare, 1, 'and returning CATTLE actually works';

--
Perl5 Master Repository

Reply via email to