summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-07-07 20:21:34 -0500
committerJesse Luehrs <doy@tozt.net>2011-07-07 20:21:34 -0500
commit5649f766a3f28cf9368305072b3351733d675e56 (patch)
tree0ede895451d51e5b9d615c2ee07380b0198470ad /lib
parentc17bd97635464c13298b177797da2fb3d02974bc (diff)
downloadsmartmatch-engine-rjbs-5649f766a3f28cf9368305072b3351733d675e56.tar.gz
smartmatch-engine-rjbs-5649f766a3f28cf9368305072b3351733d675e56.zip
make the error line up with the one used in core
Diffstat (limited to 'lib')
-rw-r--r--lib/smartmatch/engine/core.pm8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/smartmatch/engine/core.pm b/lib/smartmatch/engine/core.pm
index ee3c81e..410c983 100644
--- a/lib/smartmatch/engine/core.pm
+++ b/lib/smartmatch/engine/core.pm
@@ -4,6 +4,7 @@ use warnings;
use 5.010;
use B;
+use Carp qw(croak);
use Hash::Util::FieldHash qw(idhash);
use Scalar::Util qw(blessed looks_like_number reftype);
use overload ();
@@ -62,12 +63,11 @@ sub match {
# see http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2011-07/msg00214.html
if (!$overload && overload::Overloaded($b)) {
$overload = overload::Method($a, '~~');
- die "no ~~ overloading on $b"
- unless $overload;
- return $a->$overload($b, 0);
+ return $a->$overload($b, 0)
+ if $overload;
}
- die "no ~~ overloading on $b"
+ croak("Smart matching a non-overloaded object breaks encapsulation")
unless $overload;
return $b->$overload($a, 1);
}