Subject: | to avoid the eval in _get_obj |
Hi guys
We've encountered a warning like "Can't call method "isa" on unblessed reference" at
Hash/Merge.pm line 100
as I dug, the problem is we call _merge_hashes( $_[0], $_[1] ) when specify_behavior.
well surely, since $_[0] is hashref, the warning pops out.
_get_obj calls $_[0]->isa when ref $_[0] is not empty, though it's safe to call in an eval
block, maybe we can get rid of eval by more testing before calling $_[0]->isa?
I suggest use blessed in Scalar::Util or just skip the SCALAR|ARRAY|HASH.
the patch for the latter one is attached.
best wishes
sunnavy
Subject: | Merge.pm.diff |
--- Merge.pm 2010-02-15 23:50:11.000000000 +0800
+++ Merge.pm.new 2010-03-27 00:36:02.000000000 +0800
@@ -96,8 +96,13 @@
$GLOBAL->{'clone'} = 1;
sub _get_obj {
- if ( my $type = ref $_[0] ) {
- return shift() if $type eq __PACKAGE__ || eval { $_[0]->isa(__PACKAGE__) };
+ my $type = ref $_[0];
+
+ if ( $type
+ && $type !~ /^(?:SCALAR|ARRAY|HASH)$/
+ && ( $type eq __PACKAGE__ || $_[0]->isa(__PACKAGE__) ) )
+ {
+ return shift();
}
return $context;