When available, use metafield '__name' in error messages

This commit is contained in:
Roberto Ierusalimschy
2016-02-26 16:20:15 -03:00
parent c3e9b14d24
commit 7777b412de
3 changed files with 25 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: ldebug.c,v 2.117 2015/11/02 18:48:07 roberto Exp roberto $
** $Id: ldebug.c,v 2.118 2015/12/16 16:40:07 roberto Exp roberto $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -564,7 +564,7 @@ static const char *varinfo (lua_State *L, const TValue *o) {
l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
const char *t = objtypename(o);
const char *t = luaT_objtypename(L, o);
luaG_runerror(L, "attempt to %s a %s value%s", op, t, varinfo(L, o));
}
@@ -596,9 +596,9 @@ l_noret luaG_tointerror (lua_State *L, const TValue *p1, const TValue *p2) {
l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
const char *t1 = objtypename(p1);
const char *t2 = objtypename(p2);
if (t1 == t2)
const char *t1 = luaT_objtypename(L, p1);
const char *t2 = luaT_objtypename(L, p2);
if (strcmp(t1, t2) == 0)
luaG_runerror(L, "attempt to compare two %s values", t1);
else
luaG_runerror(L, "attempt to compare %s with %s", t1, t2);