develooper Front page | perl.perl5.porters | Postings from May 2003

Re: [perl #22238] Bizarre copy of HASH in leave

Thread Previous | Thread Next
From:
Ronald J. Kimball
Date:
May 21, 2003 08:31
Subject:
Re: [perl #22238] Bizarre copy of HASH in leave
Message ID:
20030521153051.GA1648726@linguist.thayer.dartmouth.edu
On Wed, May 21, 2003 at 03:15:07PM +0100, Dave Mitchell wrote:
> On Mon, May 19, 2003 at 11:01:31PM +0200, Abe Timmerman wrote:
> > Op een zonnige lentedag (Monday 19 May 2003 21:35), schreef Dave Mitchell:
> > 
> > > On Mon, May 19, 2003 at 02:44:57AM -0000, Andreas Koenig wrote:
> > > > Uli Pfeifer sent me this one to check agains dev perls. Yes, the bug is
> > > > confirmed against blead@19558 and maint@19553:
> > > >
> > > > % perl -Te '@{%h}{x}'
> > > > Bizarre copy of HASH in leave at -e line 1.
> > >
> > > This is just a rehash (surely a pun somewhere?) of what I reduced bug
> > > id #3420 to. I'm not sure it needs a new ticket...
> > 
> > Looking at that report and the above, I'd say they're the same.  Am I
> > right in feeling that this should be a syntax error or at least some
> > sort of funny runtime-warning like (under warnings) "Can't use '1/8' as
> > a hashref"?
> 
> No, its not a hashref, its a symbolic ref thing, eg the following
> 
>     $i = 50;
>     @{"hash".$i}{'a','b'} = (1,2)
> 
> is a roundabout way of doing
> 
>     @hash50{'a','b'} = (1,2)
> 
> ie the thing within the first set of {} braces is supposed to return a
> name to be looked up in a stash, not  a hashref.

The thing within the first set of braces should be a hash reference or an
expression which returns a name.  %h in @{%h}{x} is currently neither.
Yes, Perl could be changed so that @{%h}{x} would access e.g. ${"1/8"}{x},
but that wouldn't be useful.  In particular, it is more likely that the
programmer meant @h{x} than @{"1/8"}{x}.


> > It looks to me like the "-T" branch in the code is getting something right 
> > (except for the cryptic error).
> 
> So I think the -T branch is wrong.

I think @{%h}{x} should be a syntax error.


Ronald

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