Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 109631
Status: resolved
Priority: 0/
Queue: Moose

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

Bug Information
Severity: (no value)
Broken in: 2.1603
Fixed in: 2.1900-TRIAL



Subject: Delegation and Carping produces confusing results.
Please consider example: ---------- #!/usr/bin/perl { package BB; use Moose; use Carp; sub method { my ( $self ) = @_; Carp::croak "AAA"; }; } { package AA; use Moose; has b => ( is => 'ro', handles => [ 'method' ], builder => '_build_b', ); sub _build_b { return BB->new(); }; } my $a = AA->new(); $a->method(); ---------- Note: class AA delegates method to attribute b of class BB. Being run, the program prints: ---------- $ perl ./pod-simple-test.pl AAA at .../lib/perl5/x86_64-linux-thread-multi/Moose/Meta/Method/Delegation.pm line 110. ---------- Note: problem location is shown somewhere in Moose guts. It is quite consufing, especially for a newbie. I do not say it is a problem of Moose exclusively. The problem is located somewhere between Moose and Carp. In my little experiment, adding our @CARP_NOT = qw{ Moose::Meta::Method::Delegation }; to the class BB (!) helps to workaround the problem. $Carp::Internal{ 'Moose::Meta::Method::Delegation' } = 1; also helps. Probably Moose could add Moose::Meta::Method::Delegation to class' @CARP_NOT automatically, or set %Carp::Internal to avoid this confusing behavior?
On Tue Nov 24 19:00:28 2015, VDB wrote: Show quoted text
> Please consider example: > > ---------- > #!/usr/bin/perl > > { > package BB; > use Moose; > use Carp; > sub method { > my ( $self ) = @_; > Carp::croak "AAA"; > }; > } > > { > package AA; > use Moose; > has b => ( > is => 'ro', > handles => [ 'method' ], > builder => '_build_b', > ); > sub _build_b { > return BB->new(); > }; > } > > my $a = AA->new(); > $a->method(); > ---------- > > Note: class AA delegates method to attribute b of class BB. Being run, > the program prints: > > ---------- > $ perl ./pod-simple-test.pl > AAA at .../lib/perl5/x86_64-linux-thread- > multi/Moose/Meta/Method/Delegation.pm line 110. > ---------- > > Note: problem location is shown somewhere in Moose guts. It is quite > consufing, especially for a newbie. > > I do not say it is a problem of Moose exclusively. The problem is > located somewhere between Moose and Carp. > > In my little experiment, adding > > our @CARP_NOT = qw{ Moose::Meta::Method::Delegation }; > > to the class BB (!) helps to workaround the problem. > > $Carp::Internal{ 'Moose::Meta::Method::Delegation' } = 1; > > also helps. > > Probably Moose could add Moose::Meta::Method::Delegation to class' > @CARP_NOT automatically, or set %Carp::Internal to avoid this > confusing behavior?
I've looked into inlining delegation methods as a way to clean up stack traces, which would also fix this problem. There's a ticket for that at https://rt.cpan.org/Ticket/Display.html?id=98402
On 2015-11-24 18:34:31, DROLSKY wrote: Show quoted text
> I've looked into inlining delegation methods as a way to clean up > stack traces, which would also fix this problem. There's a ticket for > that at https://rt.cpan.org/Ticket/Display.html?id=98402
This has been merged and released as 2.1900-TRIAL.