This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid "Use of uninitialized value $res in numeric eq (==)" warning
authorJames E Keenan <jkeenan@cpan.org>
Sat, 15 Dec 2018 15:29:12 +0000 (10:29 -0500)
committerJames E Keenan <jkeenan@cpan.org>
Sat, 15 Dec 2018 15:29:12 +0000 (10:29 -0500)
The test within the SKIP block expects $res to be undef, but the 'skip'
condition itself expects it to be defined and numeric.  So we were
getting an uninitialized value warning.  In 'skip' condition, test for
definedness before numeric comparison.

ext/GDBM_File/t/fatal.t

index 01068f3..1cbfdc6 100644 (file)
@@ -52,7 +52,7 @@ my $res = eval {
 };
 
 SKIP: {
-    skip "Can't trigger failure", 2 if $res == 99;
+    skip "Can't trigger failure", 2 if (defined $res and $res == 99);
 
     is $res, undef, "eval should return undef";