[perl #47047] Use of inherited AUTOLOAD for non-method is deprecated
Rick Delaney [Tue, 30 Oct 2007 20:19:40 +0000 (13:19 -0700)]
From: Rick Delaney (via RT) <perlbug-followup@perl.org>
Message-ID: <rt-3.6.HEAD-24634-1193800780-55.47047-75-0@perl.org>

p4raw-id: //depot/perl@33302

pp_hot.c
t/lib/warnings/gv

index cd1a885..61324bf 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2735,9 +2735,14 @@ PP(pp_entersub)
        }
        /* should call AUTOLOAD now? */
        else {
-try_autoload:
+try_autoload: 
+         {
+           const bool is_method = cLISTOP->op_last &&
+               (cLISTOP->op_last->op_type == OP_METHOD_NAMED ||
+                cLISTOP->op_last->op_type == OP_METHOD);
+
            if ((autogv = gv_autoload4(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv),
-                                  FALSE)))
+                                  is_method)))
            {
                cv = GvCV(autogv);
            }
@@ -2747,6 +2752,7 @@ try_autoload:
                gv_efullname3(sub_name, gv, NULL);
                DIE(aTHX_ "Undefined subroutine &%"SVf" called", SVfARG(sub_name));
            }
+         }
        }
        if (!cv)
            DIE(aTHX_ "Not a CODE reference");
index 42565f2..6086655 100644 (file)
@@ -39,6 +39,8 @@ sub Other::AUTOLOAD { 1 } sub Other::fred {}
 @ISA = qw(Other) ;
 use warnings 'deprecated' ;
 fred() ;
+my $x = \&barney;
+(bless[])->barney;
 EXPECT
 Use of inherited AUTOLOAD for non-method main::fred() is deprecated at - line 5.
 ########