Skip Menu |

This queue is for tickets about the Class-Std-Fast CPAN distribution.

Report information
The Basics
Id: 124684
Status: open
Priority: 0/
Queue: Class-Std-Fast

People
Owner: Nobody in particular
Requestors: pratiksaha89 [...] gmail.com
Cc:
AdminCc:

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



Subject: SUPER:: is always sort-of broken
SUPER:: is always sort-of broken: * $obj->SUPER::foo will never actually use $obj for the method resolution -- it will use the *package in which the code was compiled in*. * $obj->can('SUPER::foo'), similarly, will use the "current" place in the callstack to find the next one. The problem here is that Class::Std overrides UNIVERSAL::can, so when it calls $original_can->($class, $method) and $method is SUPER::foo, the SUPER code will look at the 'current' place in the callstack.. which is the UNIVERSAL::can override in Class::Std. Whoops. In particular, this was breaking AnyEvent, which uses this lovely construct: goto &{ UNIVERSAL::can AnyEvent => "SUPER::$name" } Previously, SUPER::$name broke if Class::Std was loaded. see https://github.com/chorny/Class-Std/pull/3/commits/933aeb3063c25ee0e8a358f6465536086a590c2b by Brian Fraser and similar commit by Tom van der Woerdt
Subject: diff.txt
392c392 < if ( (my $sub_ref = $real_can->(@_)) || $method_name=~/^[()]/ ) { --- > if (my $sub_ref = $real_can->(@_)) { 410c410 < goto &$real_can; --- > return;
correct diff On Mon Mar 05 08:18:31 2018, pratiksaha89@gmail.com wrote: Show quoted text
> SUPER:: is always sort-of broken: > > * $obj->SUPER::foo will never actually use $obj for the method > resolution -- it will use the *package in which the code was > compiled in*. > * $obj->can('SUPER::foo'), similarly, will use the "current" > place in the callstack to find the next one. > > The problem here is that Class::Std overrides UNIVERSAL::can, > so when it calls $original_can->($class, $method) and $method > is SUPER::foo, the SUPER code will look at the 'current' place > in the callstack.. which is the UNIVERSAL::can override in > Class::Std. > > Whoops. > > In particular, this was breaking AnyEvent, which uses this > lovely construct: > > goto &{ UNIVERSAL::can AnyEvent => "SUPER::$name" } > > Previously, SUPER::$name broke if Class::Std was loaded. > > see https://github.com/chorny/Class- > Std/pull/3/commits/933aeb3063c25ee0e8a358f6465536086a590c2b by Brian > Fraser and similar commit by Tom van der Woerdt
Subject: diff.patch
--- /home/psaha/Downloads/Class-Std-Fast-v0.0.8/lib/Class/Std/Fast.pm 2008-05-26 13:28:58.000000000 +0200 +++ Fast.pm 2018-03-05 14:17:00.829386574 +0100 @@ -389,7 +389,7 @@ defined $_[0] or return; my ($invocant, $method_name) = @_; - if (my $sub_ref = $real_can->(@_)) { + if ( (my $sub_ref = $real_can->(@_)) || $method_name=~/^[()]/ ) { return $sub_ref; } @@ -407,7 +407,7 @@ } } - return; + goto &$real_can; }; }
On Mon Mar 05 09:04:57 2018, pratiksaha89@gmail.com wrote: Show quoted text
> correct diff > > > On Mon Mar 05 08:18:31 2018, pratiksaha89@gmail.com wrote:
> > SUPER:: is always sort-of broken: > > > > * $obj->SUPER::foo will never actually use $obj for the method > > resolution -- it will use the *package in which the code was > > compiled in*. > > * $obj->can('SUPER::foo'), similarly, will use the "current" > > place in the callstack to find the next one. > > > > The problem here is that Class::Std overrides UNIVERSAL::can, > > so when it calls $original_can->($class, $method) and $method > > is SUPER::foo, the SUPER code will look at the 'current' place > > in the callstack.. which is the UNIVERSAL::can override in > > Class::Std. > > > > Whoops. > > > > In particular, this was breaking AnyEvent, which uses this > > lovely construct: > > > > goto &{ UNIVERSAL::can AnyEvent => "SUPER::$name" } > > > > Previously, SUPER::$name broke if Class::Std was loaded. > > > > see https://github.com/chorny/Class- > > Std/pull/3/commits/933aeb3063c25ee0e8a358f6465536086a590c2b by Brian > > Fraser and similar commit by Tom van der Woerdt
This patch may not bee the correct fix. See my comment at <https://github.com/chorny/Class-Std/pull/3#issuecomment-370653445>.