Skip Menu |

This queue is for tickets about the curry CPAN distribution.

Report information
The Basics
Id: 114973
Status: new
Priority: 0/
Queue: curry

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

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



Subject: Fix edge cases for Curry::Weak
Please consider the following patch for curry::weak --- curry.pm 2012-09-09 15:35:31.000000000 -0400 +++ tmp/curry.pm 2016-06-01 17:02:51.519642509 -0400 @@ -18,11 +18,11 @@ sub AUTOLOAD { my $invocant = shift; - Scalar::Util::weaken($invocant) if Scalar::Util::blessed($invocant); + Scalar::Util::weaken($invocant) if ref $invocant; my ($method) = our $AUTOLOAD =~ /^curry::weak::(.+)$/; my @args = @_; return sub { - return unless $invocant; + return unless defined $invocant; $invocant->$method(@args => @_); } } The first change makes sure that a ref is always weakened. The ref should always be blessed anyway, but why take chances? (also, I suspect that 'ref' is faster than calling 'blessed', but have not benchmarked it) The second change fixes an actual bug where the $invocant gets stringified or bool-overload called on it when what you actually wanted to check was whether it was still an active reference. This is demonstrated by the following: perl -e 'use curry; package Foo { use overload bool => sub { 0 }; sub why_are_you_false { "Just because" }; }; my $x= bless {}, "Foo"; my $why_false= $x->curry::weak::why_are_you_false(); print $why_false->()."\n";