From 4deb77323e57d2e09af3b29ae2fe59d7e97213a4 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 27 Apr 2017 02:54:12 +1000 Subject: src/ltm.js: Fix luaT_objtypename - it tried to index the tvalue instead of the metatable - it returns a jsstring in __name case, but lua string in fallback --- src/ltm.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ltm.js b/src/ltm.js index 31a4371..9c70322 100644 --- a/src/ltm.js +++ b/src/ltm.js @@ -68,12 +68,13 @@ const luaT_init = function(L) { ** with metatable, use their '__name' metafield, if present. */ const luaT_objtypename = function(L, o) { - if ((o.ttistable() && o.metatable !== null) || (o.ttisfulluserdata() && o.metatable !== null)) { - let name = lobject.table_index(o, defs.to_luastring('__name', true)); + let mt; + if ((o.ttistable() && (mt = o.metatable) !== null) || + (o.ttisfulluserdata() && (mt = o.metatable) !== null)) { + let name = lobject.table_index(mt, defs.to_luastring('__name', true)); if (name.ttisstring()) - return name.jsstring(); + return name.value; } - return ttypename(o.ttnov()); }; -- cgit v1.2.3-70-g09d2