Subject: | failures loading modules are ignored when sub-package exists |
When base tries to load a module and finds that it doesn't exist, it
ignores the error if anything the package's stash exists. This is by
design, but causes issues when sub-packages exist.
Attached is a patch that will ignore sub-packages, while still
considering anything else in the stash as marking the package's existence.
Subject: | sub-package-fix.patch |
diff --git i/lib/base.pm w/lib/base.pm
index 19fc845..1d3db87 100644
--- i/lib/base.pm
+++ w/lib/base.pm
@@ -82,7 +82,7 @@ sub import {
# Only ignore "Can't locate" errors from our eval require.
# Other fatal errors (syntax etc) must be reported.
die if $@ && $@ !~ /^Can't locate .*? at \(eval /;
- unless (%{"$base\::"}) {
+ unless (grep { !/::$/ } keys %{"$base\::"}) {
require Carp;
local $" = " ";
Carp::croak(<<ERROR);
diff --git i/t/base.t w/t/base.t
old mode 100644
new mode 100755
index 6fb24ea..705ed8f
--- i/t/base.t
+++ w/t/base.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 11;
+use Test::More tests => 12;
use_ok('base');
@@ -55,6 +55,11 @@ like( $@, qr/^Base class package "reallyReAlLyNotexists" is empty\./,
eval q{use base 'reallyReAlLyNotexists'};
like( $@, qr/^Base class package "reallyReAlLyNotexists" is empty\./,
' still empty on 2nd load');
+eval 'sub reallyReAlLyNotexists::Sub::welp { }';
+eval q{use base 'reallyReAlLyNotexists'};
+like( $@, qr/^Base class package "reallyReAlLyNotexists" is empty\./,
+ ' empty even with sub-package existing');
+
{
my $warning;
local $SIG{__WARN__} = sub { $warning = shift };