Skip Menu |

This queue is for tickets about the Object-Lazy CPAN distribution.

Report information
The Basics
Id: 131817
Status: resolved
Priority: 0/
Queue: Object-Lazy

People
Owner: STEFFENW [...] cpan.org
Requestors: MERKYS [...] cpan.org
Cc:
AdminCc:

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



Subject: References are not passed for the building call
Consider the following MWE: Cat.pm: --------------8<-------------- package Cat; use strict; use warnings; sub new { return bless {}, $_[0] } sub store { $_[1] = 'mouse' } 1; --------------8<-------------- hunt.pl: --------------8<-------------- #!/usr/bin/perl use strict; use warnings; use Cat; use Object::Lazy; my $eager_cat = Cat->new; my $lazy_cat = Object::Lazy->new( sub { return Cat->new } ); $eager_cat->store( my $eager_out ); $lazy_cat->store( my $lazy_out ); print "Eager: $eager_out\n"; print "Lazy: $lazy_out\n"; --------------8<-------------- One would expect both the $eager_out and $lazy_out contain a string with 'mouse', however, the following output is printed: --------------8<-------------- Eager: mouse Use of uninitialized value $lazy_out in concatenation (.) or string at hunt.pl line 15. Lazy: --------------8<-------------- To me it seems that the AUTOLOAD of Object::Lazy fails to pass its parameters unmodified to the called subroutine.
The following patch fixes the issue: diff --git a/lib/Object/Lazy.pm b/lib/Object/Lazy.pm index 60189fb..cc0b0f7 100644 --- a/lib/Object/Lazy.pm +++ b/lib/Object/Lazy.pm @@ -47,12 +47,14 @@ my $build_object = sub { sub DESTROY {} # is not AUTOLOAD sub AUTOLOAD { ## no critic (Autoloading ArgUnpacking) - my ($self, @params) = @_; + my ($self) = @_; my $method = substr our $AUTOLOAD, 2 + length __PACKAGE__; my $built_object = $build_object->($self, \$_[0]); - return $built_object->$method(@params); + shift; + + return $built_object->$method(@_); } sub isa { ## no critic (ArgUnpacking)
Thank you for the ticket. Going to work on it.
fixed in 0.16
On Tue Feb 25 18:32:36 2020, STEFFENW wrote: Show quoted text
> fixed in 0.16
Thanks for the prompt action! I can confirm the issue is now solved.