summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2016-11-13 15:10:38 +0100
committerDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2016-11-14 11:06:00 +0100
commit0b077c88df88ab0d1e7e4c9d8a5a6992563912e1 (patch)
treeccee7d5c9eb71f9a4d9ab2b0d6fe3f8abbeddb20 /pp_sys.c
parent89e5a02142a942dab03bc79cac055f99a7212ed7 (diff)
downloadperl-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.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/pp_sys.c b/pp_sys.c
index b7e5f61cf8..1e1b459a1a 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -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);