Skip Menu |

This queue is for tickets about the SUPER CPAN distribution.

Report information
The Basics
Id: 21644
Status: resolved
Priority: 0/
Queue: SUPER

People
Owner: Nobody in particular
Requestors: jjore [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.14
Fixed in: (no value)



Subject: Module's ->can can't use SUPER w/o unending recursion
SUPER calls a module's own ->can() method while dispatching the $obj->SUPER call. This means a module can't use SUPER inside of its own ->can method without triggering an infinite loop. The attached test fails when a simple ->can redispatches. SUPER should detect that it's already handling ->can and avoid starting the infinite loop. The find_method method should avoid using ->can on a module that is already using SUPER for it's ->can.
Subject: can.t
#!perl use Test::More tests => 2; use Test::Exception; use strict; package Mars; sub rock_out { return 'Rrraaawwwr!'; } package Venus; use SUPER; @VENUS::isa = 'Mars'; sub new { # A generic constructor. my $class = shift @_; return bless [], $class; } sub can { my $obj = shift @_; # Delegate and make damn sure that accidental infinite # recursion is deadly for purposes of these tests. use warnings FATAL => 'recursion'; $obj->SUPER; } package main; my $obj = Venus->new; lives_ok { $obj->can('rock_out') } q[No deep recursion]; eval { is( Venus->can('rock_out'), \&Mars::rock_out, '$Class->can worked' ); }; if ($@) { fail('$Class->can worked'); }
Subject: Re: [rt.cpan.org #21644] Module's ->can can't use SUPER w/o unending recursion
Date: Wed, 27 Sep 2006 23:48:23 -0700
To: bug-SUPER [...] rt.cpan.org
From: chromatic <chromatic [...] wgz.org>
On Sunday 24 September 2006 14:02, via RT wrote: Show quoted text
> SUPER calls a module's own ->can() method while dispatching the > $obj->SUPER call. This means a module can't use SUPER inside of its own > ->can method without triggering an infinite loop. > > The attached test fails when a simple ->can redispatches. SUPER should > detect that it's already handling ->can and avoid starting the infinite > loop. > > The find_method method should avoid using ->can on a module that is > already using SUPER for it's ->can.
Thanks for the test; I think you're right. I'll fix this on the weekend. -- c
Thanks, I fixed this in 1.15 by removing a potentially mutually-recursive case. (Note though that the SUPER() method in can() needs to pass @_.)