Damn! Hit send just before noticing that this is probably fixed in 0.77. I'm sorry.

On Apr 1, 2009, at 5:17 AM, Jonathan Swartz wrote:

I was trying to figure out why extends was not loading the class in certain situations. I whittled it down to this:

  package Foo::Bar::Baz;
  use Moose;

  extends 'Foo::Bar';

  sub baz {
      $Foo::Bar::var;
  }

  1;

This fails to load Foo::Bar automatically. If line 7 is taken out, then Foo::Bar is loaded.

So then I saw the docs for Class::MOP::is_class_loaded:

    is_class_loaded ($class_name)
        This will return a boolean depending on if the
        $class_name has been loaded.

        NOTE: This does a basic check of the symbol table to try
        and determine as best it can if the $class_name is
        loaded, it is probably correct about 99% of the time.

So I guess this isn't a bug, because it's only specified to be correct 99% of the time. :)

But it's bothersome that a reference to a package variable anywhere can cause that package to fail to be loaded automatically.

I'm wondering why an $INC check wasn't sufficient for is_class_loaded?

Jon


Reply via email to