develooper Front page | perl.perl5.porters | Postings from June 2014

[perl #122150] print/printf/say/sort (...) interpreted as function limited to " " as a whitespace in front of "("

Thread Previous
From:
James E Keenan via RT
Date:
June 29, 2014 01:11
Subject:
[perl #122150] print/printf/say/sort (...) interpreted as function limited to " " as a whitespace in front of "("
Message ID:
rt-4.0.18-12936-1404004303-592.122150-15-0@perl.org
On Sat Jun 21 06:29:01 2014, avar wrote:
> 
> This is a bug report for perl from avar@cpan.org,
> generated with the help of perlbug 1.40 running under perl 5.21.2.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> This is a minor bug that's been present ever since the perl 4 era. We
> have a warning that's supposed to warn about confusing use of
> print/printf/say/sort as a function, i.e. this is OK:
> 
> $ ./perl -we 'print("")'
> 
> But this is warned about:
> 
> $ ./perl -we 'print ("")'
> print (...) interpreted as function at -e line 1.
> 
> However S_checkcomma() in toke.c that implements this just does:
> 
> if (*s == ' ' && s[1] == '(') {     /* XXX gotta be a better way */
> 
> So we will only catch cases of /\b(?:print|printf|say|sort) \(/, but
> we should instead do the equivalent of matching any non-zero
> whitespace, including newlines and tabs, i.e. something like
> /\b(?:print|printf|say|sort)\s+\(/s.
> 
> The function already uses the correct isSPACE() macro later on, the
> code just needs to be re-arranged to use that to eat up space between
> the function and "(", and warn if there's any.
> 

If we've lived with this bug for 20 years, I imagine some would say, "Why can't we live with it for another 20 years?"

More to the point, what might break if we fixed it?

Could you provide tests that would demonstrate that the bug is fixed if we do decide to fix it?

Thank you very much.
Jim Keenan

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=122150

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About