[perl #80098] Bleadperl breaks Attribute::Lexical
authorFather Chrysostomos <sprout@cpan.org>
Thu, 2 Dec 2010 16:30:51 +0000 (08:30 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 2 Dec 2010 16:38:57 +0000 (08:38 -0800)
commit1726bc11330f7a943b1e12c6dd5fa5454b90abd6
treef76fc5c513ac2d60b26d0b8da4005620d00b805f
parent1245abf13f772bd2dd1d209bf07773efca954acb
[perl #80098] Bleadperl breaks Attribute::Lexical

If

@UNIVERSAL::ISA = "a";

and

@a::ISA = "b";

then methods are searched for in these orders:

main UNIVERSAL a b
UNIVERSAL a b UNIVERSAL a b
a b UNIVERSAL a b
b UNIVERSAL a b

For method lookup, looking at a stash twice causes no problems (except
for a SUPER bug I’ve just found--to be dealt with separately).

My fix to next::method in a5cd004 which made it do a second pass with
UNIVERSAL the way gv_fetchmeth does did not take into account that it
might return its caller (sub a::foo { return shift->next::can }),
causing an infinite loop.

This patch makes it check, on the second pass, whether each stash is
the stash at the start of the MRO list and breaks if that is the case,
so the MROs are effectively:

main UNIVERSAL a b
UNIVERSAL a b
a b UNIVERSAL
b UNIVERSAL a

(which is what they are effectively already for method lookup).
ext/mro/mro.xs
t/mro/next_edgecases.t