Skip Menu |
Report information
Id: 127976
Status: resolved
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors:
Cc:
AdminCc:

Operating System: All
PatchStatus: (no value)
Severity: low
Type:
Perl Version: 5.24.0
Fixed In: (no value)



Subject: each($scalar) error message anomalies
Download (untitled) / with headers
text/plain 1.5k
In these examples, 5.12.4 represents perl before the each $scalar feature. 5.14.4 includes the feature. ./perl is 5.24-to-be, in which the feature has been removed. $ perl5.12.4 -e 'print each 1' Type of arg 1 to each must be hash or array (not constant item) at -e line 1, at EOF Execution of -e aborted due to compilation errors. $ perl5.14.4 -e 'print each 1' Type of arg 1 to each must be hash (not constant item) at -e line 1, at EOF Execution of -e aborted due to compilation errors. $ ./perl -e 'print each 1' Type of arg 1 to each must be hash (not constant item) at -e line 1, at EOF Execution of -e aborted due to compilation errors. Notice how the last two error messages are wrong. The last one is wrong because arrays are also accepted. $ perl5.12.4 -e 'print each $1' Type of arg 1 to each must be hash or array (not scalar dereference) at -e line 1, at EOF Execution of -e aborted due to compilation errors. $ perl5.14.4 -e 'print each $1' Type of argument to each on reference must be unblessed hashref or arrayref at -e line 1. $ ./perl -e 'print each $1' Experimental each on scalar is now forbidden at -e line 1. This last message is correct, but differs from the constant case. This may not be a problem (it is, after all, just an error message; not something encountered much in working code), but it does make testing a little inconvenient. The ‘hash (not constant item)’ should really be fixed, though. Should it be changed to the old ‘hash or array’, or should it change to match the ‘Experimental forbidden’ message? (Take note that each(1) was never permitted.) -- Father Chrysostomos
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 2.5k
On Sat Apr 23 14:27:58 2016, sprout wrote: Show quoted text
> In these examples, 5.12.4 represents perl before the each $scalar > feature. 5.14.4 includes the feature. ./perl is 5.24-to-be, in which > the feature has been removed. > > $ perl5.12.4 -e 'print each 1' > Type of arg 1 to each must be hash or array (not constant item) at -e > line 1, at EOF > Execution of -e aborted due to compilation errors. > $ perl5.14.4 -e 'print each 1' > Type of arg 1 to each must be hash (not constant item) at -e line 1, > at EOF > Execution of -e aborted due to compilation errors. > $ ./perl -e 'print each 1' > Type of arg 1 to each must be hash (not constant item) at -e line 1, > at EOF > Execution of -e aborted due to compilation errors. > > Notice how the last two error messages are wrong. The last one is > wrong because arrays are also accepted. > > > $ perl5.12.4 -e 'print each $1' > Type of arg 1 to each must be hash or array (not scalar dereference) > at -e line 1, at EOF > Execution of -e aborted due to compilation errors. > $ perl5.14.4 -e 'print each $1' > Type of argument to each on reference must be unblessed hashref or > arrayref at -e line 1. > $ ./perl -e 'print each $1' > Experimental each on scalar is now forbidden at -e line 1. > > This last message is correct, but differs from the constant case. > > This may not be a problem (it is, after all, just an error message; > not something encountered much in working code), but it does make > testing a little inconvenient. > > The ‘hash (not constant item)’ should really be fixed, though. Should > it be changed to the old ‘hash or array’, or should it change to match > the ‘Experimental forbidden’ message? (Take note that each(1) was > never permitted.)
I now think the old message is best in this case. Also, since some syntax errors produce multiple error messages, for the ‘Experimental forbidden’ case I suggest we give two messages, since it will be more helpful, like this: $ perl -e 'print each $1' Experimental each on scalar is now forbidden at -e line 1, at EOF Type of arg 1 to each must be hash or array (not scalar dereference) at -e line 1, at EOF Execution of -e aborted due to compilation errors. I hope to push patches after 5.24 if nobody objects. (Note also that I have discovered since by previous post that the hash functions use croak, whereas the array functions use yyerror. I propose making the hash functions also use yyerror, which allows for multiple messages and provides more diagnostic information, such as ‘at EOF’, ‘near blah blah blah’, etc.) -- Father Chrysostomos
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1013b
On Sun Apr 24 14:47:40 2016, sprout wrote: Show quoted text
> I now think the old message is best in this case. > > Also, since some syntax errors produce multiple error messages, for > the ‘Experimental forbidden’ case I suggest we give two messages, > since it will be more helpful, like this: > > $ perl -e 'print each $1' > Experimental each on scalar is now forbidden at -e line 1, at EOF > Type of arg 1 to each must be hash or array (not scalar dereference) > at -e line 1, at EOF > Execution of -e aborted due to compilation errors. > > I hope to push patches after 5.24 if nobody objects. > > (Note also that I have discovered since by previous post that the hash > functions use croak, whereas the array functions use yyerror. I > propose making the hash functions also use yyerror, which allows for > multiple messages and provides more diagnostic information, such as > ‘at EOF’, ‘near blah blah blah’, etc.)
I have pushed 69e7f50e50f and dc26b617f to address these issues. -- Father Chrysostomos


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org