Skip to content

Commit

Permalink
[perl #124387] call AUTOLOAD when DESTROY isn't defined
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycoz committed Feb 8, 2016
1 parent f05081b commit 000814d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sv.c
Expand Up @@ -6776,6 +6776,7 @@ S_curse(pTHX_ SV * const sv, const bool check_refcnt) {
if (HvNAME(stash)) {
CV* destructor = NULL;
struct mro_meta *meta;

assert (SvOOK(stash));

DEBUG_o( Perl_deb(aTHX_ "Looking for DESTROY method for %s\n",
Expand All @@ -6791,7 +6792,7 @@ S_curse(pTHX_ SV * const sv, const bool check_refcnt) {
}
else {
GV * const gv =
gv_fetchmeth_autoload(stash, "DESTROY", 7, 0);
gv_fetchmethod_pvn_flags(stash, "DESTROY", 7, GV_AUTOLOAD);
if (gv) destructor = GvCV(gv);
meta->destroy_gen = PL_sub_generation;
meta->destroy = destructor;
Expand Down
2 changes: 1 addition & 1 deletion t/op/method.t
Expand Up @@ -361,6 +361,7 @@ for my $meth (['Bar', 'Foo::Bar'],
{
fresh_perl_is(<<EOT,
package UNIVERSAL; sub AUTOLOAD { my \$c = shift; print "\$c \$AUTOLOAD\\n" }
sub DESTROY {} # prevent AUTOLOAD being called on DESTROY
package Xyz;
package main; Foo->$meth->[0]();
EOT
Expand Down Expand Up @@ -462,7 +463,6 @@ is $kalled, 1, 'calling a class method via a magic variable';
{
# [perl #124387]
local $::TODO = "AUTOLOAD not being called for DESTROY";
my $autoloaded;
package AutoloadDestroy;
sub AUTOLOAD { $autoloaded = 1 }
Expand Down

0 comments on commit 000814d

Please sign in to comment.