On Sat Aug 31 12:24:23 2013, doy@tozt.net wrote: > 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. As currently implemented, "a"->{foo} is subject to strict vars, not refs. The parser loses the distinction between "a" and the ‘a’ in $a very early on (they both compile down to const ops). This is very longstanding behaviour. Do we want to change it? I have sometimes used INC->{...} instead of $INC{...}, though probably only in one-liners. -- Father Chrysostomos --- via perlbug: queue: perl5 status: open https://rt.perl.org:443/rt3/Ticket/Display.html?id=119547Thread Previous