Skip to content

Warnings when warnings enabled(!) #2

Open
@pghmcfc

Description

@pghmcfc

I've not yet been able to track down where it's happening but in some environments I'm getting warnings enabled when the Module::Load test suite is running, and that results in lots of warnings appearing, e.g.:

Use of uninitialized value $cnt:: in concatenation (.) or string at t/02_Module-Load.t line 23.
Use of uninitialized value in hash slice at /home/stfn/.cpan/build/Module-Load-0.28-fjZxuz/blib/lib/Module/Load.pm line 20.

A full example of this can be seen at http://www.cpantesters.org/cpan/report/d259755c-7d04-11e3-a289-770048f56e94

Explicitly turning off these warnings seems to work:

--- lib/Module/Load.pm
+++ lib/Module/Load.pm
@@ -3,6 +3,7 @@ package Module::Load;
 $VERSION = '0.28';

 use strict;
+use warnings;
 use File::Spec ();

 sub import {
@@ -10,6 +11,7 @@ sub import {
     my $h; shift;

     {   no strict 'refs';
+        no warnings 'uninitialized';

         @_ or (
             *{"${who}::load"} = \&load, # compat to prev version
--- t/02_Module-Load.t
+++ t/02_Module-Load.t
@@ -2,6 +2,7 @@

 use Test::More;
 use strict;
+use warnings;

 #
 # Module::Load; test new features:
@@ -18,6 +19,7 @@ use strict;
 my ($afx, $cnt, $r, $tcode) = ('TestXYZ_', 0);

 sub _reset{
+    no warnings 'uninitialized';
     undef %{Data::Dumper::};
     undef %{XYZ::Module::};
     eval "undef %{$afx$cnt::}";

I think a better fix would be to make sure that the variables in question are always initialized though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions