New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perl mistakenly warns when $] indexes a slice #12256
Comments
From lponeil@math.umd.eduCreated by lponeil@math.umd.eduHey Perl folks. The following code dies, but shouldn't. use warnings FATAL => 'all'; Larry. Perl Info
|
From @cpansproutOn Fri Jul 06 18:01:00 2012, lponeil@math.umd.edu wrote:
Interesting: $ ./perl -Ilib -Mwarnings=syntax -e '@a{$],0}' And: $ ./perl -Ilib -Mwarnings=syntax -e '@a["]",0]' The code that produces this warning (case '@' in toke.c:yylex) scans the alphanumerics space tab $ # + - ' " followed by ] or }. So it seems to be designed to catch: $a+1 But it also catches: foo # could be a function returning a list but not ${]} (there is your workaround). And warns for syntax errors (the syntax error is fine; the warning is $ ./perl -Ilib -Mwarnings=syntax -e '@a[]' We could change it to skip the warning for the empty string or an I think that would work, without making the lexer’s heuristics overly Is there anything obviously wrong with that? -- Father Chrysostomos |
The RT System itself - Status changed from 'new' to 'open' |
From @cpansproutOn Tue Jul 31 08:55:25 2012, sprout wrote:
Yes: the source code cannot easily be accessed once one has an op. Would it be acceptable to change the warning to use an ellipsis? Would it be acceptable to remove this warning altogether? The only case -- Father Chrysostomos |
From @lizmatOn Aug 1, 2012, at 8:05 AM, Father Chrysostomos via RT wrote:
I wonder whether this warning shouldn't be removed on the grounds that: 1. it is valid Perl 6 syntax, so what are we teaching newbies anyway? Liz |
From lponeil@math.umd.eduHello Father Chrysostomos.
My officemate just called this a "gross understatement", which i Larry. |
From @nwc10On Wed, Aug 01, 2012 at 09:31:03AM +0200, Elizabeth Mattijsen wrote:
But it means something subtly different - there it's a regular lookup, here I don't think we should use "it's legal Perl 6 syntax" alone as grounds for I think that the George Bernard Shaw quote "England and America are two
With a little bit of experimenting I did manage to find one difference: $ perl -le 'sub foo (\[$@]) {}; foo $a[0]' Nicholas Clark |
From @cpansproutOn Wed Aug 01 10:59:45 2012, nicholas wrote:
The most significant different is, of course, assignment thereto. It @_[0] = /(.*)/ -- Father Chrysostomos |
From @lizmatOn Aug 1, 2012, at 7:59 PM, Nicholas Clark wrote:
Then maybe it should be. :-) Seriously, from Perl trainers I've always understood that it is always the most difficult thing for newbies to grasp. Which is why Larry decided to stick with the sigil for the type of data structure, regardless of the access / context.
And some of them you can't even express in writing. "You say potato, and I say potato". Gotcha.
Wow, that's pretty obscure. I guess you *could* argue that that's a bug, but I won't :-) Liz |
From @lizmatOn Aug 1, 2012, at 9:49 PM, Father Chrysostomos via RT wrote:
Aw, evil! But yes, an idiom that would probably be much more prevalent than the prototype issue. Liz |
From @cpansproutOn Wed Aug 01 12:57:59 2012, elizabeth wrote:
... were it not for the silly warning! -- Father Chrysostomos |
From @iabynOn Wed, Aug 01, 2012 at 09:54:31PM +0200, Elizabeth Mattijsen wrote:
There's also a context difference in the way the indices are calculated: sub f { print wantarray, "\n"; 0 } which gives $ ./perl /tmp/p 1 -- |
From @cpansproutFixed in 429a255. -- Father Chrysostomos |
From [Unknown Contact. See original ticket]Fixed in 429a255. -- Father Chrysostomos |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#114024 (status was 'resolved')
Searchable as RT114024$
The text was updated successfully, but these errors were encountered: