develooper Front page | perl.perl5.porters | Postings from April 2016

[perl #127976] each($scalar) error message anomalies

Thread Previous
From:
Father Chrysostomos
Date:
April 23, 2016 21:28
Subject:
[perl #127976] each($scalar) error message anomalies
Message ID:
rt-4.0.18-32170-1461446878-1198.127976-75-0@perl.org
# New Ticket Created by  Father Chrysostomos 
# Please include the string:  [perl #127976]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=127976 >


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


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