diff options
author | Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> | 2016-11-13 15:10:38 +0100 |
---|---|---|
committer | Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> | 2016-11-14 11:06:00 +0100 |
commit | 0b077c88df88ab0d1e7e4c9d8a5a6992563912e1 (patch) | |
tree | ccee7d5c9eb71f9a4d9ab2b0d6fe3f8abbeddb20 /pp_sys.c | |
parent | 89e5a02142a942dab03bc79cac055f99a7212ed7 (diff) | |
download | perl-0b077c88df88ab0d1e7e4c9d8a5a6992563912e1.tar.gz |
Improve error for missing tie() pacakge/method
This brings the error messages in line with the ones used for normal
method calls, despite not using call_method().
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -952,10 +952,23 @@ PP(pp_tie) * (Sorry obfuscation writers. You're not going to be given this one.) */ stash = gv_stashsv(*MARK, 0); - if (!stash || !(gv = gv_fetchmethod(stash, methname))) { - DIE(aTHX_ "Can't locate object method \"%s\" via package \"%"SVf"\"", - methname, SVfARG(SvOK(*MARK) ? *MARK : &PL_sv_no)); - } + if (!stash) { + SV *stashname = SvOK(*MARK) ? *MARK : &PL_sv_no; + if (!SvCUR(*MARK)) { + stashname = sv_2mortal(newSVpvs("main")); + } + DIE(aTHX_ "Can't locate object method \"%s\" via package \"%"SVf"\"" + " (perhaps you forgot to load \"%"SVf"\"?)", + methname, SVfARG(stashname), SVfARG(stashname)); + } + else if (!(gv = gv_fetchmethod(stash, methname))) { + /* The effective name can only be NULL for stashes that have + * been deleted from the symbol table, which this one can't + * be, since we just looked it up by name. + */ + DIE(aTHX_ "Can't locate object method \"%s\" via package \"%"HEKf"\"", + methname, HvENAME_HEK_NN(stash)); + } ENTER_with_name("call_TIE"); PUSHSTACKi(PERLSI_MAGIC); PUSHMARK(SP); |