Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of inherited AUTOLOAD for non-method is deprecated #9094

Closed
p5pRT opened this issue Oct 31, 2007 · 13 comments
Closed

Use of inherited AUTOLOAD for non-method is deprecated #9094

p5pRT opened this issue Oct 31, 2007 · 13 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Oct 31, 2007

Migrated from rt.perl.org#47047 (status was 'resolved')

Searchable as RT47047$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 31, 2007

From rick@bort.ca

This warning sometimes comes up for real methods. Attached is a patch
to fix this. The patch contains a test case which fails like this
before the fix.

lib/warnings..................................................PROG​:
# gv.c
sub Other​::AUTOLOAD { 1 } sub Other​::fred {}
@​ISA = qw(Other) ;
use warnings 'deprecated' ;
fred() ;
my $x = \&barney;
(bless[])->barney;
EXPECTED​:
Use of inherited AUTOLOAD for non-method main​::fred() is deprecated at - line 5.
GOT​:
Use of inherited AUTOLOAD for non-method main​::fred() is deprecated at - line 5.
Use of inherited AUTOLOAD for non-method main​::barney() is deprecated at - line 7.
# Failed at ../t/lib/common.pl line 190
FAILED at test 285

--
Rick Delaney
rick@​bort.ca

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 31, 2007

From rick@bort.ca

autoload.patch
diff -pruN perl-current/pp_hot.c perl-current-dev/pp_hot.c
--- perl-current/pp_hot.c	2007-10-22 11:44:08.000000000 -0400
+++ perl-current-dev/pp_hot.c	2007-10-30 22:34:01.000000000 -0400
@@ -2717,9 +2717,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);
 	    }
@@ -2729,6 +2734,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");
diff -pruN perl-current/t/lib/warnings/gv perl-current-dev/t/lib/warnings/gv
--- perl-current/t/lib/warnings/gv	2007-07-11 15:34:23.000000000 -0400
+++ perl-current-dev/t/lib/warnings/gv	2007-10-30 17:08:14.000000000 -0400
@@ -39,6 +39,8 @@ sub Other::AUTOLOAD { 1 } sub Other::fre
 @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.
 ########
@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Feb 12, 2008

From rick@bort.ca

Ping.

On Oct 30 2007, Rick Delaney wrote​:

# New Ticket Created by Rick Delaney
# Please include the string​: [perl #47047]
# in the subject line of all future correspondence about this issue.
# <URL​: http​://rt.perl.org/rt3/Ticket/Display.html?id=47047 >

The patch sent with the original message still applies cleanly.
Reattached for your convenience.

--
Rick Delaney
rick@​bort.ca

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Feb 12, 2008

From rick@bort.ca

autoload.patch
diff -pruN perl-current/pp_hot.c perl-current-dev/pp_hot.c
--- perl-current/pp_hot.c	2007-10-22 11:44:08.000000000 -0400
+++ perl-current-dev/pp_hot.c	2007-10-30 22:34:01.000000000 -0400
@@ -2717,9 +2717,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);
 	    }
@@ -2729,6 +2734,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");
diff -pruN perl-current/t/lib/warnings/gv perl-current-dev/t/lib/warnings/gv
--- perl-current/t/lib/warnings/gv	2007-07-11 15:34:23.000000000 -0400
+++ perl-current-dev/t/lib/warnings/gv	2007-10-30 17:08:14.000000000 -0400
@@ -39,6 +39,8 @@ sub Other::AUTOLOAD { 1 } sub Other::fre
 @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.
 ########
@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Feb 13, 2008

@smpeters - Status changed from 'new' to 'resolved'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Feb 13, 2008

From @smpeters

Sorry, this must have been lost in the freeze. This patch was added
with change #33302.

Thanks!

Steve Peters
steve@​fisharerojo.org

On Feb 12, 2008 12​:50 PM, Rick Delaney <rick@​bort.ca> wrote​:

Ping.

On Oct 30 2007, Rick Delaney wrote​:

# New Ticket Created by Rick Delaney
# Please include the string​: [perl #47047]
# in the subject line of all future correspondence about this issue.
# <URL​: http​://rt.perl.org/rt3/Ticket/Display.html?id=47047 >

The patch sent with the original message still applies cleanly.
Reattached for your convenience.

--
Rick Delaney
rick@​bort.ca

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Feb 14, 2008

From @rgs

On 13/02/2008, Steve Peters <steve@​fisharerojo.org> wrote​:

Sorry, this must have been lost in the freeze. This patch was added
with change #33302.

And removed with change #33307. OP_ENTERSUB, as an UNOP, doesn't have
an op_last field to be accessed; leading to unpredictable results and
other core dumps on many platforms (saw them on FreeBSD).

The correct way to get the last child is to navigate all the way
through op_sibling pointers, starting with op_first. But do we want
that in code that hot ?

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Feb 14, 2008

From rick@bort.ca

On Feb 14 2008, Rafael Garcia-Suarez wrote​:

On 13/02/2008, Steve Peters <steve@​fisharerojo.org> wrote​:

Sorry, this must have been lost in the freeze. This patch was added
with change #33302.

And removed with change #33307. OP_ENTERSUB, as an UNOP, doesn't have
an op_last field to be accessed; leading to unpredictable results and
other core dumps on many platforms (saw them on FreeBSD).

Oops, I always thought it was a LISTOP.

The correct way to get the last child is to navigate all the way
through op_sibling pointers, starting with op_first. But do we want
that in code that hot ?

Probably not.

--
Rick Delaney
rick@​bort.ca

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 24, 2016

@cpansprout - Status changed from 'resolved' to 'open'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Sep 5, 2016

From @cpansprout

On Thu Feb 14 06​:42​:54 2008, rafael wrote​:

On 13/02/2008, Steve Peters <steve@​fisharerojo.org> wrote​:

Sorry, this must have been lost in the freeze. This patch was added
with change #33302.

And removed with change #33307.

I have reapplied Rick Delaney’s test in commit 9493dad and fixed the bug another way in 1de22db.

--

Father Chrysostomos

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Sep 5, 2016

@cpansprout - Status changed from 'open' to 'pending release'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented May 30, 2017

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release today of Perl 5.26.0, this and 210 other issues have been
resolved.

Perl 5.26.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.26.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented May 30, 2017

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.