diff options
author | daurnimator <quae@daurnimator.com> | 2017-04-27 02:54:12 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-04-27 02:54:12 +1000 |
commit | 4deb77323e57d2e09af3b29ae2fe59d7e97213a4 (patch) | |
tree | 28c6bad00836578884ba5de193805a9cd339ad63 /src/ltm.js | |
parent | 67cc12f149135d7a5091ce138d3fa96e71da1f69 (diff) | |
download | fengari-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
Diffstat (limited to 'src/ltm.js')
-rw-r--r-- | src/ltm.js | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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()); }; |