develooper Front page | perl.perl5.porters | Postings from November 2018

Re: [perl #133538] refaliasing does not work

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
November 5, 2018 12:39
Subject:
Re: [perl #133538] refaliasing does not work
Message ID:
20181105123916.GE3102@iabyn.com
On Sat, Sep 22, 2018 at 02:56:46AM -0700, KES (via RT) wrote:
> my @list = ( 1, 2, 3 );
> 
> # Test 1
> my %hash =  ();
> {
>         \( @hash{qw/ a b c /} ) =  \(@list);
> }
> print %hash;  # abc
> 
> 
> values are destroed from hash when we leave the block


Now fixed in blead with the following commit:

commit b97fe865adca6799771c93fc17e9f36ae7272e72
Author:     David Mitchell <davem@iabyn.com>
AuthorDate: Mon Nov 5 12:29:27 2018 +0000
Commit:     David Mitchell <davem@iabyn.com>
CommitDate: Mon Nov 5 12:29:27 2018 +0000

    Don't localise array / hash slice ref assignment
    
    RT #133538
    
    The experimental ref assignment aliasing feature, when applied to
    array or hash slices, was treating the slice as if it was always localized;
    e.g.
    
        \(@a[3,5,7]) = \(....);
    
    was being interpreted as
    
        local \(@a[3,5,7]) = \(....);
    
    The fix is simple: check for the OPpLVAL_INTRO flag actually being set
    on the op, rather than unconditionally localising the array/hash
    elements.



-- 
"There's something wrong with our bloody ships today, Chatfield."
    -- Admiral Beatty at the Battle of Jutland, 31st May 1916.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About