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

PACKAGE::SUPER doesn't work anymore #5213

Closed
p5pRT opened this issue Mar 5, 2002 · 6 comments
Closed

PACKAGE::SUPER doesn't work anymore #5213

p5pRT opened this issue Mar 5, 2002 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 5, 2002

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

Searchable as RT8788$

@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2002

From @IlyaM

Created by ilya@abra.ru

In perl v5.6.1 syntax $obj->PACKAGE​::SUPER​::method() have been
supported but it doesn't work in v5.7.3. I've checked perl570delta,
perl571delta or perl572delta but I've found anything about it.

Test case​:

  package A;

  sub test {
  my $class = shift;
  print "test A\n";
  }

  package B;

  use base qw(A);

  package main;

  sub B​::test {
  my $class = shift;

  $class->B​::SUPER​::test();
  print "test B\n";
  }

  B->test();

In 5.6.1 it prints

test A
test B

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

Flags:
    category=core
    severity=medium

Site configuration information for perl v5.7.3:

Configured by ilya at Wed Mar  6 03:17:46 MSK 2002.

Summary of my perl5 (revision 5.0 version 7 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.4.16, archname=i686-linux
    uname='linux abra.ru 2.4.16 #1 ÐÎÄ ÄÅË 10 20:32:46 msk 2001 i686 unknown '
    config_args='-de -Dusedevel -Dprefix=/home/ilya/perl573 -Duseithreads'
    hint=previous, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=define
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O3',
    cppflags='-fno-strict-aliasing -I/usr/local/include -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    ccversion='', gccversion='2.95.4 20011006 (Debian prerelease)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldb -ldl -lm -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
    libc=/lib/libc-2.2.4.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.7.3:
    /home/ilya/perl-lib
    /home/ilya/perl573/lib/5.7.3/i686-linux
    /home/ilya/perl573/lib/5.7.3
    /home/ilya/perl573/lib/site_perl/5.7.3/i686-linux
    /home/ilya/perl573/lib/site_perl/5.7.3
    /home/ilya/perl573/lib/site_perl
    .


Environment for perl v5.7.3:
    HOME=/home/ilya
    LANG=ru_RU.KOI8-R
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/ilya/bin:/home/ilya/Office51/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games
    PERL5LIB=/home/ilya/perl-lib
    PERL_BADLANG (unset)
    SHELL=/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Mar 6, 2002

From @andk

If it is a bug (and it really looks like one), it came with patch
10205 (CC'd to the author)

--
andreas

On Wed, 6 Mar 2002 05​:12​:10 +0300 (MSK), ilya@​martynov.org (Ilya Martynov) said​:

  > In perl v5.6.1 syntax $obj->PACKAGE​::SUPER​::method() have been
  > supported but it doesn't work in v5.7.3. I've checked perl570delta,
  > perl571delta or perl572delta but I've found anything about it.

  > Test case​:

  > package A;

  > sub test {
  > my $class = shift;
  > print "test A\n";
  > }

  > package B;

  > use base qw(A);

  > package main;

  > sub B​::test {
  > my $class = shift;

  > $class->B​::SUPER​::test();
  > print "test B\n";
  > }

B-> test();

  > In 5.6.1 it prints

  > test A
  > test B

  > 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]
  > -----------------------------------------------------------------
  > ---
  > Flags​:
  > category=core
  > severity=medium
  > ---
  > Site configuration information for perl v5.7.3​:

  > Configured by ilya at Wed Mar 6 03​:17​:46 MSK 2002.

  > Summary of my perl5 (revision 5.0 version 7 subversion 3) configuration​:
  > Platform​:
  > osname=linux, osvers=2.4.16, archname=i686-linux
  > uname='linux abra.ru 2.4.16 #1 ÐÎÄ ÄÅË 10 20​:32​:46 msk 2001 i686 unknown '
  > config_args='-de -Dusedevel -Dprefix=/home/ilya/perl573 -Duseithreads'
  > hint=previous, useposix=true, d_sigaction=define
  > usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
  > useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
  > use64bitint=undef use64bitall=undef uselongdouble=undef
  > usemymalloc=n, bincompat5005=define
  > Compiler​:
  > cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  > optimize='-O3',
  > cppflags='-fno-strict-aliasing -I/usr/local/include -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
  > ccversion='', gccversion='2.95.4 20011006 (Debian prerelease)', gccosandvers=''
  > intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  > d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  > ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  > alignbytes=4, prototype=define
  > Linker and Libraries​:
  > ld='cc', ldflags =' -L/usr/local/lib'
  > libpth=/usr/local/lib /lib /usr/lib
  > libs=-lnsl -ldb -ldl -lm -lc -lcrypt -lutil
  > perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
  > libc=/lib/libc-2.2.4.so, so=so, useshrplib=false, libperl=libperl.a
  > Dynamic Linking​:
  > dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
  > cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

  > Locally applied patches​:
 

  > ---
  > @​INC for perl v5.7.3​:
  > /home/ilya/perl-lib
  > /home/ilya/perl573/lib/5.7.3/i686-linux
  > /home/ilya/perl573/lib/5.7.3
  > /home/ilya/perl573/lib/site_perl/5.7.3/i686-linux
  > /home/ilya/perl573/lib/site_perl/5.7.3
  > /home/ilya/perl573/lib/site_perl
  > .

  > ---
  > Environment for perl v5.7.3​:
  > HOME=/home/ilya
  > LANG=ru_RU.KOI8-R
  > LANGUAGE (unset)
  > LD_LIBRARY_PATH (unset)
  > LOGDIR (unset)
  > PATH=/home/ilya/bin​:/home/ilya/Office51/bin​:/usr/local/bin​:/usr/bin​:/bin​:/usr/X11R6/bin​:/usr/games
  > PERL5LIB=/home/ilya/perl-lib
  > PERL_BADLANG (unset)
  > SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Apr 4, 2002

From [Unknown Contact. See original ticket]

On Wed, 6 Mar 2002, Andreas J. Koenig wrote​:

On Wed, 6 Mar 2002 05​:12​:10 +0300 (MSK), ilya@​martynov.org (Ilya Martynov) said​:
In perl v5.6.1 syntax $obj->PACKAGE​::SUPER​::method() have been
supported but it doesn't work in v5.7.3. I've checked perl570delta,
perl571delta or perl572delta but I've found anything about it.

If it is a bug (and it really looks like one), it came with patch
10205 (CC'd to the author)

Sorry, I missed this e-mail since it got filed in my p5p folder, which I
didn't check since I'm not on the list anymore. Hence the late reply.

Yes, it does seem I've introduced a bug in gv_fetchmethod_autoload().
Here's a pseudopatch to fix it. (Not tested, and not in proper patch
format. I don't actually have the sources here, I'm just cutting and
pasting from the repository browser. Pathetic, isn't it?)

  }
- 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);
+ }
  }

--
Ilmari Karonen - http​://www.sci.fi/~iltzu/
"... programs that work in spite of themselves are not what should be
guiding language design." -- Sean M. Burke on the perl5-porters list

@p5pRT
Copy link
Author

p5pRT commented Apr 4, 2002

From @jhi

On Fri, Apr 05, 2002 at 01​:35​:08AM +0300, Ilmari Karonen wrote​:

On Wed, 6 Mar 2002, Andreas J. Koenig wrote​:

On Wed, 6 Mar 2002 05​:12​:10 +0300 (MSK), ilya@​martynov.org (Ilya Martynov) said​:
In perl v5.6.1 syntax $obj->PACKAGE​::SUPER​::method() have been
supported but it doesn't work in v5.7.3. I've checked perl570delta,
perl571delta or perl572delta but I've found anything about it.

If it is a bug (and it really looks like one), it came with patch
10205 (CC'd to the author)

Sorry, I missed this e-mail since it got filed in my p5p folder, which I
didn't check since I'm not on the list anymore. Hence the late reply.

Yes, it does seem I've introduced a bug in gv_fetchmethod_autoload().
Here's a pseudopatch to fix it. (Not tested, and not in proper patch
format. I don't actually have the sources here, I'm just cutting and
pasting from the repository browser. Pathetic, isn't it?)

\}

- 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);
+ }
}

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
  From​: Ilmari Karonen <iltzu@​sci.fi>
  Date​: Fri, 5 Apr 2002 01​:35​:08 +0300 (EET DST)
  Message-ID​: <Pine.SOL.3.96.1020405004632.9372C-100000@​simpukka>

Affected files ...

.... //depot/perl/gv.c#171 edit
.... //depot/perl/t/op/method.t#22 edit

Differences ...

==== //depot/perl/gv.c#171 (text) ====
Index​: perl/gv.c

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);

==== //depot/perl/t/op/method.t#22 (xtext) ==== Index​: perl/t/op/method\.t
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");
+
End of Patch.

--
$jhi++; # http​://www.iki.fi/jhi/
  # There is this special biologist word we use for 'stable'.
  # It is 'dead'. -- Jack Cohen

@p5pRT
Copy link
Author

p5pRT commented Nov 30, 2002

From @rspier

#8788 and #17340 can be closed.

--
Ilya Martynov, ilya@​iponweb.net

@p5pRT
Copy link
Author

p5pRT commented Nov 30, 2002

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant