=head1 New or Changed Diagnostics
+=over 4
+
+=item (perhaps you forgot to load "%s"?)
+
+(F) This is an educated guess made in conjunction with the message
+"Can't locate object method \"%s\" via package \"%s\"". It often means
+that a method requires a package that has not been loaded.
+
+=back
+
=head1 New tests
=head1 Incompatible Changes
functioning as a class, but that package doesn't define that particular
method, nor does any of its base classes. See L<perlobj>.
+=item (perhaps you forgot to load "%s"?)
+
+(F) This is an educated guess made in conjunction with the message
+"Can't locate object method \"%s\" via package \"%s\"". It often means
+that a method requires a package that has not been loaded.
+
=item Can't locate package %s for @%s::ISA
(W syntax) The @ISA array contained the name of another package that
char* leaf = name;
char* sep = Nullch;
char* p;
+ GV* gv;
for (p = name; *p; p++) {
if (*p == '\'')
packname = name;
packlen = sep - name;
}
- Perl_croak(aTHX_
- "Can't locate object method \"%s\" via package \"%s\"",
- leaf, packname);
+ gv = gv_fetchpv(packname, 0, SVt_PVHV);
+ if (gv && isGV(gv)) {
+ Perl_croak(aTHX_
+ "Can't locate object method \"%s\" via package \"%s\"",
+ leaf, packname);
+ }
+ else {
+ Perl_croak(aTHX_
+ "Can't locate object method \"%s\" via package \"%s\"
+ " (perhaps you forgot to load \"%s\"?)",
+ leaf, packname, packname);
+ }
}
return isGV(gv) ? (SV*)GvCV(gv) : (SV*)gv;
}
# test method calls and autoloading.
#
-print "1..49\n";
+print "1..53\n";
@A::ISA = 'B';
@B::ISA = 'C';
test(do { eval 'A2::foo()'; $@ ? 1 : 0}, 1);
test(A2->foo(), "foo");
}
+
+{
+ test(do { use Config; eval 'Config->foo()';
+ $@ =~ /^\QCan't locate object method "foo" via package "Config" at/ ? 1 : $@}, 1);
+ test(do { use Config; eval '$d = bless {}, "Config"; $d->foo()';
+ $@ =~ /^\QCan't locate object method "foo" via package "Config" at/ ? 1 : $@}, 1);
+}
+
+test(do { eval 'E->foo()';
+ $@ =~ /^\QCan't locate object method "foo" via package "E" (perhaps / ? 1 : $@}, 1);
+test(do { eval '$e = bless {}, "E"; $e->foo()';
+ $@ =~ /^\QCan't locate object method "foo" via package "E" (perhaps / ? 1 : $@}, 1);
+