From: Mike Guy Date: Fri, 11 Jan 2002 18:36:33 +0000 (+0000) Subject: Correct misleading error message X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b21befc10a2adba57c505b26af5b35adc507bf13;p=p5sagit%2Fp5-mst-13.2.git Correct misleading error message Message-Id: hash assignment -> anonymous hash p4raw-id: //depot/perl@14200 --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 777b0dd..af78458 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -2370,6 +2370,11 @@ See also L 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 8b58c16..319adaf 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 2f4bf7b..5ed7aa0 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 8466a71..3db2b46 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 ];