diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-11-19 18:21:46 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-11-19 18:21:46 -0800 |
commit | a9ea019aef3b2976fab5d804799be8a75f0de48d (patch) | |
tree | f18638e886bce98dc0053f2e25b2110d35374583 /t | |
parent | 0e82bbcd2c141a233d06826ca4011728c8287daf (diff) | |
download | perl-a9ea019aef3b2976fab5d804799be8a75f0de48d.tar.gz |
Make sort’s warnings dependent on the right hints
sort’s warnings about uninitialized (or non-numeric) values returned
from comparison routines are emitted in the scope of the compar-
ison routine, not the sort function itself. So, not only does
‘use warnings; sort...’ not always warn, but the line numbers can be
off, too:
$ ./perl -Ilib -e '()=sort flobbp 1,2;' -e'use warnings;sub flobbp{"foo"}'
Argument "foo" isn't numeric in sort at -e line 2.
The solution is to restore PL_curcop to its previous value before get-
ting a number out of the comparison routine’s return value.
Diffstat (limited to 't')
-rw-r--r-- | t/lib/warnings/9uninit | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/t/lib/warnings/9uninit b/t/lib/warnings/9uninit index 495f570499..e0c7320fdf 100644 --- a/t/lib/warnings/9uninit +++ b/t/lib/warnings/9uninit @@ -635,6 +635,11 @@ sub sortf {$a-1 <=> $b-1}; @sort = sort { undef } 1, 2; sub frobnicate($$) { undef } @sort = sort frobnicate 1, 2; +@sort = sort pyfg 1, 2; +@sort = sort pyfgc 1, 2; +no warnings; +sub pyfg { undef } +sub pyfgc($$) { undef } EXPECT Use of uninitialized value $m1 in sort at - line 6. Use of uninitialized value $g1 in sort at - line 6. @@ -653,7 +658,9 @@ Use of uninitialized value $m1 in sort at - line 9. Use of uninitialized value $g1 in sort at - line 9. Use of uninitialized value $g1 in sort at - line 9. Use of uninitialized value in sort at - line 10. -Use of uninitialized value in sort at - line 11. +Use of uninitialized value in sort at - line 12. +Use of uninitialized value in sort at - line 13. +Use of uninitialized value in sort at - line 14. ######## my $nan = sin 9**9**9; if ($nan == $nan) { |