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

Re: [perl #119547] 42->{42} works in strict mode

Thread Previous | Thread Next
From:
Jesse Luehrs
Date:
August 31, 2013 19:23
Subject:
Re: [perl #119547] 42->{42} works in strict mode
Message ID:
20130831192345.GH15882@tozt.members.linode.com
On Sat, Aug 31, 2013 at 12:12:16PM -0700, GlitchMr wrote:
> Following code doesn't fail, when it should (42 is symbolic ref)
> 
>     use strict;
>     42->{42};
> 
> This code also doesn't fail.
> 
>     use strict;
>     sub CONSTANT() { 42 }
>     CONSTANT->{42};
> 
> But this does correctly fail.
> 
>     use strict;
>     sub { 42 }->()->{42};
>     # Can't use string ("42") as a HASH ref while "strict refs" in
>     use...

This bug appears to have been present for quite some time (if not
forever):

  $ perl -le'print $]'
  5.006002
  $ perl -le'*{"42"} = {foo => "bar"}; use strict; print 42->{foo}'
  bar
  $ perl -le'*{"42"} = {foo => "bar"}; use strict; print "42"->{foo}'
  bar
  $ perl -le'*{"42a"} = {foo => "bar"}; use strict; print "42a"->{foo}'
  bar
  $ perl -le'*{"a"} = {foo => "bar"}; use strict; print "a"->{foo}'
  Global symbol "%a" requires explicit package name at -e line 1.
  Execution of -e aborted due to compilation errors.

-doy

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