On Mon, Jul 01, 2002 at 09:57:24AM -0500, Andy Lester wrote:
> I can do this:
>
> use PHP::Session 0.10;
>
> to ensure a version number, but I can't do this:
>
> use_ok( 'PHP::Session', '0.10' );
>
> because I get this error:
>
> alester@flr4[~/tw/Dev]$ more Modules.t
> #!/usr/bin/perl -w
>
> use strict;
> use Test::More tests => 1;
>
> use_ok( 'PHP::Session', '0.10' );
>
>
> alester@flr4[~/tw/Dev]$ perl Modules.t
> 1..1
> not ok 1 - use PHP::Session;
> # Failed test (Modules.t at line 6)
> # Tried to use 'PHP::Session'.
> # Error: Can't locate object method "require_version" via package
>"PHP::Session" (perhaps you forgot to load "PHP::Session"?) at
>/usr/local/lib/perl5/5.6.1/Exporter/Heavy.pm line 105.
> # Looks like you failed 1 tests of 1.
>
> ....
>
> Before I go digging into a patch, is this something that we even want to
> allow? I know I'd like to allow it, because I'd like to have one .t
> file that ensures that I have proper module prereqs for my entire source
> tree.
This is due to a quirk in the way "use Foo VERSION" is handled.
use PHP::Session 0.10;
this is handled directly by Perl itself and uses UNIVERSAL::VERSION to get
$PHP::Session::VERSION.
require PHP::Session;
PHP::Session->import(0.10);
In this case, PHP::Session::import would be used, or an inherited method,
usually Exporter::import. But PHP::Session doesn't inherit from Exporter,
yet we're winding up in there anyway.
The problem is, using PHP::Session is defining a UNIVERSAL::import somehow.
DB<1> x defined &UNIVERSAL::import
0 ''
DB<2> use PHP::Session
DB<3> x defined &UNIVERSAL::import
0 1
PHP::Session uses UNIVERSAL::require which has to use UNIVERSAL.pm for an
obscure ambiguity warning [1]. UNIVERSAL.pm does
require Exporter;
*import = \&Exporter::import;
so all classes suddenly have an import method, but they never inherited from
Exporter! So Bad Things happen. The fact that UNIVERSAL.pm has an import
method is a historical accident.
It's only limited to situations when UNIVERSAL.pm is loaded. Since "use
UNIVERSAL" is rather pointless, I'm going to change UNIVERSAL::require so it
no longer pre-loads UNIVERSAL.pm and tell the Email::Valid author to remove
his "use UNIVERSAL" line which is what started the problem in the first
place.
[1] To see this bug, download UNIVERSAL::require 0.02 and do:
$ cd UNIVERSAL-exports-0.02
$ perl -Ilib -MUNIVERSAL::require -MUNIVERSAL -wle 1
Ambiguous call resolved as CORE::require(), qualify as such or use & at
/usr/share/perl/5.6.1/UNIVERSAL.pm line 6.
--
This sig file temporarily out of order.