for instance, when it has been deleted
Eval::Closure (which should hopefully be fixed soon). Based on code and bug
report from Carlos Lima. RT #74650.
+ * Fix a segfault when adding a method to a class which was defined in a
+ package which was deleted. (doy)
+
2.0402 Sat, Feb 04, 2012
[OTHER]
*/
if ( isGV_with_GP(CvGV(coderef)) ) {
- GV *gv = CvGV(coderef);
- *pkg = HvNAME( GvSTASH(gv) ? GvSTASH(gv) : CvSTASH(coderef) );
- *name = GvNAME( CvGV(coderef) );
+ GV *gv = CvGV(coderef);
+ HV *stash = GvSTASH(gv) ? GvSTASH(gv) : CvSTASH(coderef);
+
+ *pkg = stash ? HvNAME(stash) : "__UNKNOWN__";
+ *name = GvNAME( CvGV(coderef) );
} else {
- *pkg = "__UNKNOWN__";
- *name = "__ANON__";
+ *pkg = "__UNKNOWN__";
+ *name = "__ANON__";
}
return 1;
--- /dev/null
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+use Moose ();
+
+{
+ package Foo;
+ sub bar { 'BAR' }
+}
+
+my $method = \&Foo::bar;
+
+{
+ no strict 'refs';
+ delete ${'::'}{'Foo::'};
+}
+
+my $meta = Moose::Meta::Class->create('Bar');
+$meta->add_method(bar => $method);
+is(Bar->bar, 'BAR');
+
+done_testing;