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
Subs ending in { @a } return list, not hashref; can Perl defend against this trap? #12078
Comments
From @jimavThis is a bug report for perl from james_avera@yahoo.com, In the following, Perl silently parses the {...} in the last line use struct; use warnings; This is a trap. Can Perl do something to save programmers from it? One solution might be to actually recognize when {...} is the last thing Another might be to warn about *statements* consisting only of Flags: Site configuration information for perl 5.12.4: Configured by Debian Project at Tue Sep 6 08:08:24 UTC 2011. Summary of my perl5 (revision 5 version 12 subversion 4) configuration: Platform: Locally applied patches: @INC for perl 5.12.4: Environment for perl 5.12.4: PATH=/home/jima/bin:/home/jima/local/bin:/home/jima/jima_tools/linux86_64/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/bin/X11:/usr/local/bin:/opt/openoffice.org3/program:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/games:. |
From @TuxOn Wed, 02 May 2012 12:39:45 -0700, Jim Avera (via RT)
Yes, either put a + in front of the opening brace or add an explicit sub f sub g
This issue comes back every now and then, and whatever way the current
No. Many people use this to explicitely create a scope, possibly with -- |
The RT System itself - Status changed from 'new' to 'open' |
From @nwc10On Thu, May 03, 2012 at 11:10:43AM +0200, H.Merijn Brand wrote:
We could make return statements mandatory :-)
Worse than that, I think it's not possible. Too much lookahead would be needed,
I think the key part of the request was that all code *within* the block However, I'm not sure how easy it is to "know" unambiguously whether a Nicholas Clark |
From @AbigailOn Wed, May 02, 2012 at 12:39:45PM -0700, Jim Avera wrote:
Subs of the form: sub foo { or sub bar { are as common as dirt; I don't think people appreciate it if this starts Abigail |
From @ikegamiOn Thu, May 3, 2012 at 5:10 AM, H.Merijn Brand <h.m.brand@xs4all.nl> wrote:
I often have code of the form sub { If that last block becomes a hash, I'd likely get spurious warnings |
From zefram@fysh.orgThe documentation of the hash/block disambiguation method was recently -zefram |
@iabyn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#112732 (status was 'resolved')
Searchable as RT112732$
The text was updated successfully, but these errors were encountered: