summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorMax Maischein <corion@corion.net>2019-10-25 20:20:56 +0200
committerMax Maischein <github@corion.net>2019-11-03 20:39:47 +0100
commit448aac914b0b0182b7d462d88f99a40dc08b6d9e (patch)
treeb3dc3d73db3027666a2ccdc91d71434444e917f7 /gv.c
parentcf4ed238de1f463909da889917a8b1d17ae2f012 (diff)
downloadperl-448aac914b0b0182b7d462d88f99a40dc08b6d9e.tar.gz
And silence some silly examples.
From RT88754 Adapted to the current Perl by Max Maischein Created from https://github.com/Perl/perl5/issues/11259
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/gv.c b/gv.c
index 3cb182eb01..1a49d5e192 100644
--- a/gv.c
+++ b/gv.c
@@ -713,6 +713,7 @@ S_gv_fetchmeth_internal(pTHX_ HV* stash, SV* meth, const char* name, STRLEN len,
CV* cand_cv = NULL;
GV* topgv = NULL;
const char *hvname;
+ STRLEN hvnamelen;
I32 create = (level >= 0) ? HV_FETCH_LVALUE : 0;
I32 items;
U32 topgen_cmp;
@@ -728,6 +729,7 @@ S_gv_fetchmeth_internal(pTHX_ HV* stash, SV* meth, const char* name, STRLEN len,
assert(stash);
hvname = HvNAME_get(stash);
+ hvnamelen = HvNAMELEN_get(stash);
if (!hvname)
Perl_croak(aTHX_ "Can't use anonymous symbol table for method lookup");
@@ -797,10 +799,30 @@ S_gv_fetchmeth_internal(pTHX_ HV* stash, SV* meth, const char* name, STRLEN len,
cstash = gv_stashsv(linear_sv, 0);
if (!cstash) {
- Perl_ck_warner(aTHX_ packWARN(WARN_SYNTAX),
- "Can't locate package %" SVf " for @%" HEKf "::ISA",
- SVfARG(linear_sv),
- HEKfARG(HvNAME_HEK(stash)));
+ if ( ckWARN(WARN_SYNTAX)) {
+ if( /* these are loaded from Perl_Gv_AMupdate() one way or another */
+ ( len && name[0] == '(' ) /* overload.pm related, in particular "()" */
+ || ( memEQs( name, len, "DESTROY") )
+ ) {
+ Perl_ck_warner(aTHX_ packWARN(WARN_SYNTAX),
+ "Can't locate package %" SVf " for @%" HEKf "::ISA",
+ SVfARG(linear_sv),
+ HEKfARG(HvNAME_HEK(stash)));
+
+ } else if( memEQs( name, len, "AUTOLOAD") ) {
+ /* gobble this warning */
+ } else {
+ Perl_ck_warner(aTHX_ packWARN(WARN_SYNTAX),
+ "While trying to resolve method call %.*s->%.*s()"
+ " can not locate package \"%"SVf"\" yet it is mentioned in @%.*s::ISA"
+ " (perhaps you forgot to load \"%"SVf"\"?)",
+ hvnamelen, hvname,
+ len, name,
+ SVfARG(linear_sv),
+ hvnamelen, hvname,
+ SVfARG(linear_sv));
+ }
+ }
continue;
}