This commit is contained in:
Roberto Ierusalimschy
2024-01-29 14:29:24 -03:00
parent 108e0bdc84
commit c31d6774ac
7 changed files with 25 additions and 24 deletions

7
ltm.c
View File

@@ -92,10 +92,9 @@ const char *luaT_objtypename (lua_State *L, const TValue *o) {
Table *mt;
if ((ttistable(o) && (mt = hvalue(o)->metatable) != NULL) ||
(ttisfulluserdata(o) && (mt = uvalue(o)->metatable) != NULL)) {
TValue name;
int hres = luaH_getshortstr(mt, luaS_new(L, "__name"), &name);
if (hres == HOK && ttisstring(&name)) /* is '__name' a string? */
return getstr(tsvalue(&name)); /* use it as type name */
const TValue *name = luaH_Hgetshortstr(mt, luaS_new(L, "__name"));
if (ttisstring(name)) /* is '__name' a string? */
return getstr(tsvalue(name)); /* use it as type name */
}
return ttypename(ttype(o)); /* else use standard type name */
}