aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-04-27 02:54:12 +1000
committerdaurnimator <quae@daurnimator.com>2017-04-27 02:54:12 +1000
commit4deb77323e57d2e09af3b29ae2fe59d7e97213a4 (patch)
tree28c6bad00836578884ba5de193805a9cd339ad63
parent67cc12f149135d7a5091ce138d3fa96e71da1f69 (diff)
downloadfengari-4deb77323e57d2e09af3b29ae2fe59d7e97213a4.tar.gz
fengari-4deb77323e57d2e09af3b29ae2fe59d7e97213a4.tar.bz2
fengari-4deb77323e57d2e09af3b29ae2fe59d7e97213a4.zip
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
-rw-r--r--src/ltm.js9
1 files 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());
};