summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorVincent Pit <perl@profvince.com>2008-05-01 14:45:51 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2008-05-02 11:07:19 +0000
commite67b97bd974194ad616acbb7813c5631aacd6be7 (patch)
treee32b15786d8137b66c0931484bcaab84464780b7 /pp_ctl.c
parentaa472d819afa513557c8ae076693d2c753998ed1 (diff)
downloadperl-e67b97bd974194ad616acbb7813c5631aacd6be7.tar.gz
~~ with non-overloaded objects
From: "Vincent Pit" <perl@profvince.com> Message-ID: <63496.92.128.104.139.1209638751.squirrel@92.128.104.139> p4raw-id: //depot/perl@33777
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 08c6d700c8..261b1be2e2 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -4012,6 +4012,11 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
&& (Other = d)) )
+# define SM_OBJECT ( \
+ (sv_isobject(d) && (SvTYPE(SvRV(d)) != SVt_REGEXP)) \
+ || \
+ (sv_isobject(e) && (SvTYPE(SvRV(e)) != SVt_REGEXP)) ) \
+
# define SM_OTHER_REF(type) \
(SvROK(Other) && SvTYPE(SvRV(Other)) == SVt_##type)
@@ -4043,6 +4048,9 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
if (SvGMAGICAL(e))
e = sv_mortalcopy(e);
+ if (SM_OBJECT)
+ Perl_croak(aTHX_ "Smart matching a non-overloaded object breaks encapsulation");
+
if (SM_CV_NEP) {
I32 c;