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

Report information
The Basics

Nobody in particular
julien.ollivier [...]

Broken in:
Fixed in:
(no value)

Subject: CUMULATIVE(BASE FIRST) methods don't get any arguments passed to them, including $self
When a user-defined method is marked as CUMULATIVE(BASE FIRST), the initialize() routine of Class::Std does not pass the arguments of the call to the anticumulative methods. The problem is in lines 375, 380, and 383 (lines numbers refer to v0.0.8). As we can see, the arguments (@args) aren't being passed : 374 if (!defined $list_context) { 375 &{$sub_ref}; 376 next; 377 } 378 push @classes, $parent; 379 if ($list_context) { 380 push @results, &{$sub_ref}; 381 } 382 else { 383 push @results, scalar &{$sub_ref}; 384 } Constrast this to when the method is a regular (leaf first) CUMULATIVE, when everything works fine. Indeed it is informative to examine lines 327-337 below, for the (leaf first) cumulative case where we get the correct behaviour. I'm not sure why the calling style is different in each case, but I suspect line 375 is supposed to look like line 328, 380 like 333, and 383 like 336. In a nutshell, the author omitted to supply "@args" when calling methods in the anticumulative case, but not in the cumulative case. 327 if (!defined $list_context) { 328 $sub_ref->(@args); 329 next; 330 } 331 push @classes, $parent; 332 if ($list_context) { 333 push @results, $sub_ref->(@args); 334 } 335 else { 336 push @results, scalar $sub_ref->(@args); 337 } The end result is I can't even do my $self = shift; as I get an undefined value. This bug is patently obvious and trivial to fix so I am not including any sample code that exercises it. However, generally any attempt at accessing attributes within a BASE FIRST method will fail due to this bug since $self is not passed as an argument. I am using perl v5.8.6. This is my first bug report. I don't know what happens from here. I plan to workaround this bug unless there is a systematic way to install the patch, because I run my program on several machines and don't want to fix it manually on each one. Any suggestions there? Julien P.S. Great module Damian! I am using it a lot and this is the first problem I find.
I noticed that the first cumulative method called works fine because it appears that @_ is magically passed to it with the correct arguments. However, executing my $self = shift; wreaks havoc on the argument list for the leaf methods. In the normal cumulative call, the argument list is copied so the problem doesn't occur. Hence, a simple workaround to this problem is to copy the argument list: my $self = $_[0]; my $other_arg = $_[1]; etc.

This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with to