develooper Front page | perl.perl5.porters | Postings from October 2005

Re: [PATCH] Re: [perl #37350] $#{@$aref} in debugger gives: Bizarre copy of ARRAY in leave

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
October 12, 2005 04:41
Subject:
Re: [PATCH] Re: [perl #37350] $#{@$aref} in debugger gives: Bizarre copy of ARRAY in leave
Message ID:
20051012114214.GL4432@iabyn.com
On Wed, Oct 12, 2005 at 02:18:12AM -0700, Yitzchak Scott-Thoennes wrote:
> I think the problem is that that the first executed (of two) rv2av is
> getting the OPf_REF flag set, when IMO it shouldn't.  $#{@x} *is*
> valid syntax; it should return $# of the array symbolically referred
> to by @x, like this:
> 
> $ perl -we'*1 = [qw/foo bar baz/]; @x=0; print $#{0+@x}'
> 2
> 
> only without the 0+ being there.  (If @x is lexical, then it's padav
> that has the troublesome OPf_REF.)

It's because Perl_ref() recursively sets the OPf_REF flag in the following
in perly.y:

	|	arylen 	%prec '('                    /* $#x, $#{ something } */
			{ $$ = newUNOP(OP_AV2ARYLEN, 0, ref($1, OP_AV2ARYLEN));}

That particuar problem can be fixed by replacing the call to ref() above
with a direct $1->op_flags |= OPf_REF, but that doesn't solve the more
general problem with things like push @{@a}, ...., which also gets the
recursive Perl_ref() treatment. Possibly it can be fixed in Perl_ref()?




-- 
Art is anything that has a label (especially if the label is "untitled 1")

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