-
Notifications
You must be signed in to change notification settings - Fork 567
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
Hash keys are not always parsed as strings if the arrow is omitted #4688
Comments
From @AbigailCreated by abigail@hermione.osp.nl use strict; This fails to compile with the message: Bareword "colour" not allowed while "strict subs" in use at q.pl line 2. There's no problem if we add the optional arrow, or if we quote the use strict; blue use strict; blue The same happens in 5.6.1. Perl Info
|
From pepe@cpan.orgThis is a bug report for perl from pepe@cpan.org, Hi, $ perl -lwe 'my $foo = sub { return {xyz => 42}; }; print $foo->()->{xyz}' $ perl -lwe 'my $foo = sub { return {xyz => 42}; }; print $foo->(){xyz}' $ perl -lwe 'my $foo = sub { return {length => 42}; }; print $foo->()->{length}' $ perl -lwe 'my $foo = sub { return {length => 42}; }; print $foo->(){length}' In the second and fourth line, the arrow between "()" and "{...}" was omitted. I would think that hash keys in curlies are always parsed as strings, perlref says: Similarly, because of all the subscripting that is done using single words, we've $array{ "aaa" }{ "bbb" }{ "ccc" } you can write just $array{ aaa }{ bbb }{ ccc } and not worry about whether the subscripts are reserved words. While () is not a real subscript, this is no reason to treat the Cheers, Flags: Site configuration information for perl 5.10.1: Configured by Debian Project at Sun Feb 7 13:06:31 UTC 2010. Summary of my perl5 (revision 5 version 10 subversion 1) configuration: Locally applied patches: @INC for perl 5.10.1: Environment for perl 5.10.1: |
From @AbigailOn Wed, Apr 21, 2010 at 08:26:08AM -0700, Christoph Bussenius wrote:
This is a duplicate of #8045, which has been open since 2001. Abigail |
The RT System itself - Status changed from 'new' to 'open' |
From rob.dixon@gmx.comThis is a bug report for perl from rob.dixon@gmx.com, use strict; my $hashsub = sub { # These work fine print $hashsub->()->{key}, "\n"; # But this throws `Bareword "key" not allowed while "strict subs" in use` print $hashsub->(){key}, "\n"; Flags: Site configuration information for perl 5.16.2: Configured by strawberry-perl at Fri Nov 2 00:34:53 2012. Summary of my perl5 (revision 5 version 16 subversion 2) configuration: Locally applied patches: @INC for perl 5.16.2: Environment for perl 5.16.2: Flags: Site configuration information for perl 5.16.2: Configured by strawberry-perl at Fri Nov 2 00:34:53 2012. Summary of my perl5 (revision 5 version 16 subversion 2) configuration: Locally applied patches: @INC for perl 5.16.2: Environment for perl 5.16.2: |
From @jkeenanOn Wed Jun 12 09:49:51 2013, rob.dixon@gmx.com wrote:
Problem confirmed, but it should be noted that 'use 5.016;' can be
(x86)\PHP\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
(x86)\Lua\5.1\clibs;C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;C:\Program
10.0\VC\bin\amd64;C:\SWIG;C:\MinGW\bin;C:\MinGW\MSYS\1.0\bin;C:\Python27;C:\Curl;C:\pkg-
(x86)\PHP\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
(x86)\Lua\5.1\clibs;C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;C:\Program
10.0\VC\bin\amd64;C:\SWIG;C:\MinGW\bin;C:\MinGW\MSYS\1.0\bin;C:\Python27;C:\Curl;C:\pkg-
|
The RT System itself - Status changed from 'new' to 'open' |
From @cpansproutOn Wed Jun 12 09:49:51 2013, rob.dixon@gmx.com wrote:
Thank you for the report. BTW, this is a duplicate of #8045. -- Father Chrysostomos |
From zefram@fysh.orgFor this problem to occur, it is not sufficient that the arrow preceding $ perl -lwe '$a = sub { +{a=>5} }; print $a->(){"a"} - 1' This dates right back to the introduction of arrow-omitted syntax in I've fixed it in commit 097ff42. -zefram |
From @jkeenanI have confirmed that the posters' examples now work as intended. Resolving ticket pending release. Thank you very much. -- |
@jkeenan - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release yesterday of Perl 5.28.0, this and 185 other issues have been Perl 5.28.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#8045 (status was 'resolved')
Searchable as RT8045$
The text was updated successfully, but these errors were encountered: