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

[perl #113554] my() with empty list causes weird error

Thread Next
From:
Reini Urban via RT
Date:
June 25, 2012 07:29
Subject:
[perl #113554] my() with empty list causes weird error
Message ID:
rt-3.6.HEAD-5009-1340634557-290.113554-15-0@perl.org
On Sun Jun 24 22:44:27 2012, doy wrote:
> Fixed in 8b8c1fb. It looks like this was a bug that was fixed during 
the
> course of MAD development, but was added back into the core with 
#ifdef
> PERL_MAD just because it was different from the existing core code.
> 
> (Also, for future reference: 'stub' is the name of the internal perl
> opcode which generates the '()' construct. See �perl -MO=Concise -
E'my
> @x = ()'� for instance.)

I disagree.

The error message is not weird, it is consistent with all perls, and it 
should be an error. If the compiler detects an invalid declaration it 
should help the author and not silently allow to do nothing.

Re the consistency argument: Why allow now empty declarations? This 
makes it inconsistent.

Why should "my ();" parse correctly?
Why should "my;" parse correctly? Both are clearly syntax errors.
$ perl -e"my;"
syntax error at -e line 1, near "my;"



$ perlall -m do -e '"my ();"'
/usr/local/bin/perl5.16.0-nt -e "my ();"
Can't declare stub in "my" at -e line 1, near ");"
Execution of -e aborted due to compilation errors.
/usr/local/bin/perl5.14.2-nt -e "my ();"
Can't declare stub in "my" at -e line 1, near ");"
Execution of -e aborted due to compilation errors.
/usr/local/bin/perl5.12.4 -e "my ();"
sh: 1: /usr/local/bin/perl5.12.4: not found
/usr/local/bin/perl5.10.1-nt -e "my ();"
Can't declare stub in "my" at -e line 1, near ");"
Execution of -e aborted due to compilation errors.
/usr/local/bin/perl5.8.9d -e "my ();"
Can't declare stub in "my" at -e line 1, near ");"
Execution of -e aborted due to compilation errors.
/usr/local/bin/perl5.8.8d-nt -e "my ();"
Can't declare stub in "my" at -e line 1, near ");"
Execution of -e aborted due to compilation errors.
/usr/local/bin/perl5.8.5d-nt -e "my ();"
Can't declare stub in "my" at -e line 1, near ");"
Execution of -e aborted due to compilation errors.
/usr/local/bin/perl5.8.4d-nt -e "my ();"
Can't declare stub in "my" at -e line 1, near ");"
Execution of -e aborted due to compilation errors.
/usr/local/bin/perl5.6.2-nt -e "my ();"
Can't declare stub in "my" at -e line 1, near ");"
Execution of -e aborted due to compilation errors.

Please revert 8b8c1fb. This broke it, and did not fix it.
For consistency with older perls I would also not change the error 
message, but maybe explain it in a pod, if we would have a 
pod with all parser/compiler-time error messages collected.
A "stub" is an empty expression placeholder to me.
-- 
Reini Urban

---
via perlbug:  queue: perl5 status: resolved
https://rt.perl.org:443/rt3/Ticket/Display.html?id=113554

Thread Next


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