diff options
author | Aaron Crane <arc@cpan.org> | 2017-01-24 19:50:32 +0000 |
---|---|---|
committer | Aaron Crane <arc@cpan.org> | 2017-01-24 20:01:48 +0000 |
commit | 32207c637b216a1dfa7317d111af89f149743ff3 (patch) | |
tree | 4138bd2307e9ffc66dc1f60b0a0fbe9b712fce78 /pp_sys.c | |
parent | 769b28f489b6336875b378e2e47e731628f45af0 (diff) | |
download | perl-32207c637b216a1dfa7317d111af89f149743ff3.tar.gz |
RT#130623: assertions when tying into non-packages
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -953,13 +953,26 @@ PP(pp_tie) */ stash = gv_stashsv(*MARK, 0); if (!stash) { - SV *stashname = SvOK(*MARK) ? *MARK : &PL_sv_no; - if (!SvCUR(*MARK)) { - stashname = sv_2mortal(newSVpvs("main")); + if (SvROK(*MARK)) + DIE(aTHX_ "Can't locate object method \"%s\" via package \"%" SVf "\"", + methname, SVfARG(*MARK)); + else if (isGV(*MARK)) { + /* If the glob doesn't name an existing package, using + * SVfARG(*MARK) would yield "*Foo::Bar" or *main::Foo. So + * generate the name for the error message explicitly. */ + SV *stashname = newSV(0); + gv_fullname4(stashname, (GV *) *MARK, NULL, FALSE); + DIE(aTHX_ "Can't locate object method \"%s\" via package \"%" SVf "\"", + methname, SVfARG(stashname)); + } + else { + SV *stashname = !SvPOK(*MARK) ? &PL_sv_no + : SvCUR(*MARK) ? *MARK + : 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)); } - 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 |