So I figured maybe if I unwound that stack trace I might get more help, so
here it is, in reverse order:
perl -MMoose # explosion!
# In Moose.pm
use Moose::Meta::TypeCoercion;
#################################################
# In Moose::Meta::TypeCoercion;
__PACKAGE__->meta->add_attribute(
Moose::Meta::Attribute->new('type_constraint' => (
reader => 'type_constraint',
weak_ref => 1
))
);
#################################################
# In Class::MOP::Class
sub add_attribute {
my $self = shift;
# either we have an attribute object already
# or we need to create one from the args provided
my $attribute = blessed($_[0]) ? $_[0] :
$self->attribute_metaclass->new(@_);
# make sure it is derived from the correct type though
($attribute->isa('Class::MOP::Attribute'))
|| confess "Your attribute must be an instance of
Class::MOP::Attribute (or a subclass)";
# first we attach our new attribute
# because it might need certain information
# about the class which it is attached to
$attribute->attach_to_class($self);
# then we remove attributes of a conflicting
# name here so that we can properly detach
# the old attr object, and remove any
# accessors it would have generated
if ( $self->has_attribute($attribute->name) ) {
$self->remove_attribute($attribute->name);
} else {
$self->invalidate_meta_instances();
}
# get our count of previously inserted attributes and
# increment by one so this attribute knows its order
my $order = (scalar keys %{$self->get_attribute_map}) - 1;
$attribute->_set_insertion_order($order + 1);
# then onto installing the new accessors
$self->get_attribute_map->{$attribute->name} = $attribute;
# invalidate package flag here
my $e = do {
local $@;
local $SIG{__DIE__};
eval { $attribute->install_accessors() };
$@;
};
if ( $e ) {
$self->remove_attribute($attribute->name);
die $e;
}
return $attribute;
}
#################################################
# In Moose::Meta::Attribute
sub install_accessors {
my $self = shift;
$self->SUPER::install_accessors(@_);
$self->install_delegation if $self->has_handles;
return;
}
#################################################
# In Class::MOP::Attribute
sub install_accessors {
my $self = shift;
my $inline = shift;
my $class = $self->associated_class;
$class->add_method(
$self->_process_accessors('accessor' => $self->accessor(), $inline)
) if $self->has_accessor();
# this is the line
$class->add_method(
$self->_process_accessors('reader' => $self->reader(), $inline)
) if $self->has_reader();
$class->add_method(
$self->_process_accessors('writer' => $self->writer(), $inline)
) if $self->has_writer();
$class->add_method(
$self->_process_accessors('predicate' => $self->predicate(),
$inline)
) if $self->has_predicate();
$class->add_method(
$self->_process_accessors('clearer' => $self->clearer(), $inline)
) if $self->has_clearer();
return;
}
#################################################
# In Class::MOP::Attribute
sub _process_accessors {
my ($self, $type, $accessor, $generate_as_inline_methods) = @_;
my $method_ctx;
if ( my $ctx = $self->definition_context ) {
$method_ctx = { %$ctx };
}
if (ref($accessor)) {
(ref($accessor) eq 'HASH')
|| confess "bad accessor/reader/writer/predicate/clearer format,
must be a HASH ref";
my ($name, $method) = %{$accessor};
$method = $self->accessor_metaclass->wrap(
$method,
package_name => $self->associated_class->name,
name => $name,
definition_context => $method_ctx,
);
$self->associate_method($method);
return ($name, $method);
}
else {
my $inline_me = ($generate_as_inline_methods &&
$self->associated_class->instance_metaclass->is_inlinable);
my $method;
eval {
if ( $method_ctx ) {
my $desc = "accessor $accessor";
if ( $accessor ne $self->name ) {
$desc .= " of attribute " . $self->name;
}
$method_ctx->{description} = $desc;
}
$method = $self->accessor_metaclass->new(
attribute => $self,
is_inline => $inline_me,
accessor_type => $type,
package_name => $self->associated_class->name,
name => $accessor,
definition_context => $method_ctx,
);
};
# here obviously
confess "Could not create the '$type' method for " . $self->name . "
because : $@" if $@;
$self->associate_method($method);
return ($accessor, $method);
}
}
#################################################
And then last but not least:
# Moose::Meta::Attribute
sub throw_error {
my $self = shift;
my $class = ( ref $self && $self->associated_class ) ||
"Moose::Meta::Class";
unshift @_, "message" if @_ % 2 == 1;
unshift @_, attr => $self if ref $self;
unshift @_, $class;
my $handler = $class->can("throw_error"); # to avoid incrementing depth
by 1
goto $handler;
}
Hope this helps :-)
On Thu, Jul 9, 2009 at 11:32 PM, fREW Schmidt <[email protected]> wrote:
> Hey guys,
>
> I updated everything that I could in CPAN and somehow it destroyed my moose
> install. This is what happens when I try to run my Cat app:
>
> Use of uninitialized value in goto at
> /usr/local/share/perl/5.10.0/Moose/Meta/Attribute.pm line 74.
> Could not create the 'reader' method for type_constraint because : goto
> must have label at /usr/local/share/perl/5.10.0/Moose/Meta/Attribute.pm line
> 74.
> at /usr/local/lib/perl/5.10.0/Class/MOP/Attribute.pm line 390
>
> Class::MOP::Attribute::_process_accessors('Moose::Meta::Attribute=HASH(0x94eccd0)',
> 'reader', 'type_constraint', undef) called at
> /usr/local/lib/perl/5.10.0/Class/MOP/Attribute.pm line 405
>
> Class::MOP::Attribute::install_accessors('Moose::Meta::Attribute=HASH(0x94eccd0)')
> called at /usr/local/share/perl/5.10.0/Moose/Meta/Attribute.pm line 538
>
> Moose::Meta::Attribute::install_accessors('Moose::Meta::Attribute=HASH(0x94eccd0)')
> called at /usr/local/lib/perl/5.10.0/Class/MOP/Class.pm line 864
> eval {...} called at /usr/local/lib/perl/5.10.0/Class/MOP/Class.pm
> line 864
>
> Class::MOP::Class::add_attribute('Class::MOP::Class=HASH(0x93adc68)',
> 'Moose::Meta::Attribute=HASH(0x94eccd0)') called at
> /usr/local/share/perl/5.10.0/Moose/Meta/TypeCoercion.pm line 20
> require Moose/Meta/TypeCoercion.pm called at
> /usr/local/share/perl/5.10.0/Moose.pm line 19
> Moose::BEGIN() called at
> /usr/local/share/perl/5.10.0/Moose/Meta/TypeCoercion.pm line 0
> eval {...} called at
> /usr/local/share/perl/5.10.0/Moose/Meta/TypeCoercion.pm line 0
> require Moose.pm called at
> /usr/local/share/perl/5.10.0/Catalyst/Engine/HTTP.pm line 3
> Catalyst::Engine::HTTP::BEGIN() called at
> /usr/local/share/perl/5.10.0/Moose/Meta/TypeCoercion.pm line 0
> eval {...} called at
> /usr/local/share/perl/5.10.0/Moose/Meta/TypeCoercion.pm line 0
> require Catalyst/Engine/HTTP.pm called at script/glimmer_server.pl
> line 6
> main::BEGIN() called at
> /usr/local/share/perl/5.10.0/Moose/Meta/TypeCoercion.pm line 0
> eval {...} called at
> /usr/local/share/perl/5.10.0/Moose/Meta/TypeCoercion.pm line 0
> Compilation failed in require at /usr/local/share/perl/5.10.0/Moose.pm line
> 19.
> BEGIN failed--compilation aborted at /usr/local/share/perl/5.10.0/Moose.pm
> line 19.
> Compilation failed in require at
> /usr/local/share/perl/5.10.0/Catalyst/Engine/HTTP.pm line 3.
> BEGIN failed--compilation aborted at
> /usr/local/share/perl/5.10.0/Catalyst/Engine/HTTP.pm line 3.
> Compilation failed in require at script/glimmer_server.pl line 6.
> BEGIN failed--compilation aborted at script/glimmer_server.pl line 7.
>
>
> I tried to reinstall both Moose and Class::MOP. Class::MOP reinstalled
> fine, but reinstalling Moose gives the same errors as this. Any help guys?
>
> --
> fREW Schmidt
> http://blog.afoolishmanifesto.com
>
--
fREW Schmidt
http://blog.afoolishmanifesto.com