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
PACKAGE::SUPER doesn't work anymore #5213
Comments
From @IlyaMCreated by ilya@abra.ruIn perl v5.6.1 syntax $obj->PACKAGE::SUPER::method() have been Test case: package A; sub test { package B; use base qw(A); package main; sub B::test { $class->B::SUPER::test(); B->test(); In 5.6.1 it prints test A 5.7.3 dies with message Can't locate object method "test" via package "B::SUPER" (perhaps you forgot to load "B::SUPER"?) at t.pl line 17. Perl Info
|
From @andkIf it is a bug (and it really looks like one), it came with patch --
> In perl v5.6.1 syntax $obj->PACKAGE::SUPER::method() have been > Test case: > package A; > sub test { > package B; > use base qw(A); > package main; > sub B::test { > $class->B::SUPER::test(); B-> test(); > In 5.6.1 it prints > test A > 5.7.3 dies with message > Can't locate object method "test" via package "B::SUPER" (perhaps you forgot to load "B::SUPER"?) at t.pl line 17. > [Please do not change anything below this line] > Configured by ilya at Wed Mar 6 03:17:46 MSK 2002. > Summary of my perl5 (revision 5.0 version 7 subversion 3) configuration: > Locally applied patches: > --- > --- |
From [Unknown Contact. See original ticket]On Wed, 6 Mar 2002, Andreas J. Koenig wrote:
Sorry, I missed this e-mail since it got filed in my p5p folder, which I Yes, it does seem I've introduced a bug in gv_fetchmethod_autoload(). } -- |
From @jhiOn Fri, Apr 05, 2002 at 01:35:08AM +0300, Ilmari Karonen wrote:
Nice pathetic work there. Change 15737 by jhi@alpha on 2002/04/04 22:28:32 Subject: Re: [ID 20020305.025] PACKAGE::SUPER doesn't work anymore Affected files ... .... //depot/perl/gv.c#171 edit Differences ... ==== //depot/perl/gv.c#171 (text) ==== Inline Patch--- perl/gv.c.~1~ Fri Apr 5 02:31:41 2002
+++ perl/gv.c Fri Apr 5 02:31:41 2002
@@ -422,9 +422,17 @@
DEBUG_o( Perl_deb(aTHX_ "Treating %s as %s::%s\n",
origname, HvNAME(stash), name) );
}
- else
+ else {
/* don't autovifify if ->NoSuchStash::method */
stash = gv_stashpvn(origname, nsplit - origname, FALSE);
+
+ /* however, explicit calls to Pkg::SUPER::method may
+ happen, and may require autovivification to work */
+ if (!stash && (nsplit - origname) >= 7 &&
+ strnEQ(nsplit - 7, "::SUPER", 7) &&
+ gv_stashpvn(origname, nsplit - origname - 7, FALSE))
+ stash = gv_stashpvn(origname, nsplit - origname, TRUE);
+ }
}
gv = gv_fetchmeth(stash, name, nend - name, 0);
Inline Patch--- perl/t/op/method.t.~1~ Fri Apr 5 02:31:41 2002
+++ perl/t/op/method.t Fri Apr 5 02:31:41 2002
@@ -10,7 +10,7 @@
require "test.pl";
}
-print "1..74\n";
+print "1..75\n";
@A::ISA = 'B';
@B::ISA = 'C';
@@ -259,3 +259,21 @@
is($w, '');
}
+# [ID 20020305.025] PACKAGE::SUPER doesn't work anymore
+
+package main;
+our @X;
+package Amajor;
+sub test {
+ push @main::X, 'Amajor', @_;
+}
+package Bminor;
+use base qw(Amajor);
+package main;
+sub Bminor::test {
+ $_[0]->Bminor::SUPER::test('x', 'y');
+ push @main::X, 'Bminor', @_;
+}
+Bminor->test('y', 'z');
+is("@X", "Amajor Bminor x y Bminor Bminor y z");
+
-- |
@rspier - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#8788 (status was 'resolved')
Searchable as RT8788$
The text was updated successfully, but these errors were encountered: