
ikegami at adaelis
Nov 22, 2009, 3:48 PM
Post #1 of 1
(182 views)
Permalink
|
|
[PATCH] [perl #67838] lvalue substr keeping lexical alive
|
|
On Wed, Nov 18, 2009 at 1:01 PM, Eric Brine <ikegami [at] adaelis> wrote: > My next step will be figuring out whether lvalue subs can't return TEMPs > because it can't be done or because it hasn't been implemented. > It simply appears to be the case that the original coder forgot that TEMPs could be magical. No problem or memory leaks occur if they are returned. In fact, the sub was previously patched to allow a TEMP to be returned from an lvalue sub when it's a tied element. Without it, the following would not work: use Tie::Array; tie my @a, Tie::StdArray:: @a = qw( a b c ); sub f :lvalue { $a[0] } f() = 'd'; Therefore, the solution is to extend the aforementioned exception to SVs with any type of Set magic (instead of just those with tiedelem magic). Attached is the test patch (unchanged) and an updated fix patch the addresses all problems and passes all tests. - Eric
|