develooper Front page | perl.perl5.porters | Postings from April 2014

[perl #121766] Creating accessor method using SUPER name stopped to work

Thread Previous
From:
Tony Cook via RT
Date:
April 30, 2014 06:31
Subject:
[perl #121766] Creating accessor method using SUPER name stopped to work
Message ID:
rt-4.0.18-29484-1398839463-1119.121766-15-0@perl.org
On Tue Apr 29 15:13:01 2014, migo@freeshell.org wrote:
> The following test program demonstrates a regression in perl 5.18:
> 
> 	@Class2::ISA = qw(Class1);
> 	sub Class1::AUTOLOAD {
> 		*{$Class1::AUTOLOAD} = sub { print "defined\n" };
> 		print "autoloaded\n";
> 	}
> 
> 	Class2->Class2::SUPER::a;
> 	Class2->Class2::SUPER::a;
> 	Class2->a;
> 	Class2->a;
> 
> In perl versions prior to 5.18.0 it prints:
> 
> 	autoloaded
> 	defined
> 	autoloaded
> 	defined
> 
> In 5.18.0 (and 5.18.2) it prints "autoloaded" 3 times in a row.
> And Class2->can('Class2::SUPER::a') returns undef instead of CODE,
> although the method gets re-defined every time, causing warnings
> "Subroutine SubClass::SUPER::method redefined" in my real code.

Bisected to:

aae438050a206a8067e068319ab3ee2348009463 is the first bad commit
commit aae438050a206a8067e068319ab3ee2348009463
Author: Father Chrysostomos <sprout@cpan.org>
Date:   Mon Sep 17 16:24:40 2012 -0700

    [perl #114924] Make method calls work with ::SUPER packages
    
    Perl caches SUPER methods inside packages named Foo::SUPER.  But this
    interferes with actual method calls on those packages (SUPER->foo,
    foo::SUPER->foo).
    
    The first time a package is looked up, it is vivified under the name
    with which it is looked up.  So *SUPER:: will cause that package
    to be called SUPER, and *main::SUPER:: will cause it to be named
    main::SUPER.
    
    main->SUPER::isa used to be very sensitive to the name of the
    main::FOO package (where the cache is kept).  If it happened to be
    called SUPER, that call would fail.
    ...
    
Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=121766

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About