From ad20689febfe15e20c9bce6bb74459f169499524 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 10 Nov 2014 12:46:05 -0200 Subject: [PATCH] better error message for bitwise operators (they are not arithmetic...) --- ldebug.h | 7 ++++--- ltm.c | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ldebug.h b/ldebug.h index 6e1dfd28..7fba153c 100644 --- a/ldebug.h +++ b/ldebug.h @@ -1,5 +1,5 @@ /* -** $Id: ldebug.h,v 2.10 2013/05/06 17:19:11 roberto Exp roberto $ +** $Id: ldebug.h,v 2.11 2014/02/25 14:31:16 roberto Exp roberto $ ** Auxiliary functions from Debug Interface module ** See Copyright Notice in lua.h */ @@ -25,8 +25,9 @@ LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *opname); LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, const TValue *p2); -LUAI_FUNC l_noret luaG_aritherror (lua_State *L, const TValue *p1, - const TValue *p2); +LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, + const TValue *p2, + const char *msg); LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, const TValue *p2); LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, diff --git a/ltm.c b/ltm.c index 94c077d5..f4625627 100644 --- a/ltm.c +++ b/ltm.c @@ -1,5 +1,5 @@ /* -** $Id: ltm.c,v 2.29 2014/07/18 13:36:14 roberto Exp roberto $ +** $Id: ltm.c,v 2.30 2014/11/02 19:19:04 roberto Exp roberto $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -122,10 +122,12 @@ void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, lua_Number dummy; if (tonumber(p1, &dummy) && tonumber(p2, &dummy)) luaG_tointerror(L, p1, p2); + else if (event != TM_IDIV) + luaG_opinterror(L, p1, p2, "perform bitwise operation on"); /* else go through */ } default: - luaG_aritherror(L, p1, p2); + luaG_opinterror(L, p1, p2, "perform arithmetic on"); } } }