summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pod/perldiag.pod5
-rw-r--r--pp.c2
-rw-r--r--t/lib/warnings/pp2
-rwxr-xr-xt/op/hashwarn.t5
4 files changed, 10 insertions, 4 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 777b0dd80a..af78458acb 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -2370,6 +2370,11 @@ See also L<perlport> for writing portable code.
(W) The call to overload::constant contained an odd number of arguments.
The arguments should come in pairs.
+=item Odd number of elements in anonymous hash
+
+(W misc) You specified an odd number of elements to initialize a hash,
+which is odd, because hashes come in key/value pairs.
+
=item Odd number of elements in hash assignment
(W misc) You specified an odd number of elements to initialize a hash,
diff --git a/pp.c b/pp.c
index 8b58c167a4..319adafc7e 100644
--- a/pp.c
+++ b/pp.c
@@ -3848,7 +3848,7 @@ PP(pp_anonhash)
if (MARK < SP)
sv_setsv(val, *++MARK);
else if (ckWARN(WARN_MISC))
- Perl_warner(aTHX_ WARN_MISC, "Odd number of elements in hash assignment");
+ Perl_warner(aTHX_ WARN_MISC, "Odd number of elements in anonymous hash");
(void)hv_store_ent(hv,key,val,0);
}
SP = ORIGMARK;
diff --git a/t/lib/warnings/pp b/t/lib/warnings/pp
index 2f4bf7b068..5ed7aa0891 100644
--- a/t/lib/warnings/pp
+++ b/t/lib/warnings/pp
@@ -67,7 +67,7 @@ my $a = { 1,2,3};
no warnings 'misc' ;
my $b = { 1,2,3};
EXPECT
-Odd number of elements in hash assignment at - line 3.
+Odd number of elements in anonymous hash at - line 3.
########
# pp.c
use warnings 'misc' ;
diff --git a/t/op/hashwarn.t b/t/op/hashwarn.t
index 8466a7196e..3db2b46917 100755
--- a/t/op/hashwarn.t
+++ b/t/op/hashwarn.t
@@ -45,7 +45,8 @@ sub test_warning ($$$) {
# print "# $num: $got\n";
}
-my $odd_msg = '/^Odd number of elements in hash/';
+my $odd_msg = '/^Odd number of elements in hash assignment/';
+my $odd_msg2 = '/^Odd number of elements in anonymous hash/';
my $ref_msg = '/^Reference found where even-sized list expected/';
{
@@ -56,7 +57,7 @@ my $ref_msg = '/^Reference found where even-sized list expected/';
test_warning 2, shift @warnings, $odd_msg;
%hash = { 1..3 };
- test_warning 3, shift @warnings, $odd_msg;
+ test_warning 3, shift @warnings, $odd_msg2;
test_warning 4, shift @warnings, $ref_msg;
%hash = [ 1..3 ];