develooper Front page | perl.perl5.porters | Postings from September 2013

[perl #119797] lvalue sub shows "Bizarre copy of ARRAY in block exit" in very specific case.

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
September 15, 2013 18:26
Subject:
[perl #119797] lvalue sub shows "Bizarre copy of ARRAY in block exit" in very specific case.
Message ID:
rt-3.6.HEAD-1873-1379269574-1980.119797-15-0@perl.org
On Sun Sep 15 09:10:35 2013, jkeenan wrote:
> On Sun Sep 15 07:10:48 2013, sprout wrote:
> > On Sun Sep 15 06:21:00 2013, jkeenan wrote:
> > > ##########
> > > $ cat 119797-lvalue.pl 
> > > my @this = (1..5);
> > > 
> > > (that()) = ();
> > > print "@this\n";
> > > 
> > > sub that :lvalue { if (@this) { } else { @this; } }
> > > ##########
> > > $ perl 119797-lvalue.pl 
> > > 1 2 3 4 5
> > > ##########
> > > 
> > > I don't think there is a bug here.
> > 
> > Your version puts something in the array, avoiding the else block.
> > 
> > Try this:
> > 
> > #!perl
> > my @this = ();
> > 
> > (that()) = ();
> > print "@this\n";
> > 
> > sub that :lvalue { if (@this) { } else { @this; } }
> > __END__
> > 
> > That gives me a bizarre copy.
> > 
> 
> 
> Okay.  So now we should ask:  How significant is this bug?

It’s low priority, as the workaround (explicit return) is simple.

> What can we
> do to fix it?

I suspect skipping the leave op when followed by leavesublv would work.
 In fact, skipping it for any sub (not just lvalue) would probably make
implicit return faster in general.

That would entail nulling it (via op_null(...)) in S_finalize_op in op.c.

(That’s without looking at the code, so it could be all wrong.)

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=119797

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