On Fri Jul 06 18:01:00 2012, lponeil@math.umd.edu wrote: > This is a bug report for perl from lponeil@math.umd.edu, > generated with the help of perlbug 1.39 running under perl 5.14.2. > > > ----------------------------------------------------------------- > [Please describe your issue here] > > Hey Perl folks. > > The following code dies, but shouldn't. > > use warnings FATAL => 'all'; > my @a = 0..9; print @a[$],0]; > > Larry. Interesting: $ ./perl -Ilib -Mwarnings=syntax -e '@a{$],0}' Scalar value @a{$] better written as $a{$] at -e line 1. And: $ ./perl -Ilib -Mwarnings=syntax -e '@a["]",0]' Scalar value @a["] better written as $a["] at -e line 1. $ ./perl -Ilib -Mwarnings=syntax -e '@a["}",0]' Scalar value @a["} better written as $a["} at -e line 1. The code that produces this warning (case '@' in toke.c:yylex) scans the source following the [ or { for zero or more of these: alphanumerics space tab $ # + - ' " followed by ] or }. So it seems to be designed to catch: $a+1 -1 2 $#foo --$_ $_++ 'foo' "foo" But it also catches: foo # could be a function returning a list $] "]" "}" qw"foo bar" # see ticket #28380 but not ${]} (there is your workaround). And warns for syntax errors (the syntax error is fine; the warning is weird): $ ./perl -Ilib -Mwarnings=syntax -e '@a[]' Scalar value @a[] better written as $a[] at -e line 1. syntax error at -e line 1, near "[]" Execution of -e aborted due to compilation errors. We could change it to skip the warning for the empty string or an initial alphanumeric character. Instead of warning immediately, the lexer could flag the op, and the compiler could then look to see whether there is indeed just one kidop and warn. I think that would work, without making the lexer’s heuristics overly complex. Is there anything obviously wrong with that? -- Father Chrysostomos --- via perlbug: queue: perl5 status: new https://rt.perl.org:443/rt3/Ticket/Display.html?id=114024Thread Previous | Thread Next