From 8f36e70e354c7af1f82d27f406d02a0bf9528b45 Mon Sep 17 00:00:00 2001 From: yexo Date: Sun, 11 Dec 2011 15:52:18 +0000 Subject: (svn r23496) -Fix: [Squirrel] Provide a proper error message when the _cmp meta-function doesn't return an integer --- src/3rdparty/squirrel/squirrel/sqvm.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/3rdparty') diff --git a/src/3rdparty/squirrel/squirrel/sqvm.cpp b/src/3rdparty/squirrel/squirrel/sqvm.cpp index b4ff85d95..dae5ff4a2 100644 --- a/src/3rdparty/squirrel/squirrel/sqvm.cpp +++ b/src/3rdparty/squirrel/squirrel/sqvm.cpp @@ -195,14 +195,19 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result) case OT_INSTANCE: if(_delegable(o1)->_delegate) { Push(o1);Push(o2); - if(CallMetaMethod(_delegable(o1),MT_CMP,2,res)) break; + if(CallMetaMethod(_delegable(o1),MT_CMP,2,res)) { + if(type(res) != OT_INTEGER) { + Raise_Error(_SC("_cmp must return an integer")); + return false; + } + _RET_SUCCEED(_integer(res)) + } } //continues through (no break needed) default: _RET_SUCCEED( _userpointer(o1) < _userpointer(o2)?-1:1 ); } - if(type(res)!=OT_INTEGER) { Raise_CompareError(o1,o2); return false; } - _RET_SUCCEED(_integer(res)); + assert(0); } else{ -- cgit v1.2.3-70-g09d2