summaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lapi.js b/src/lapi.js
index e323e4f..1dfd112 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -697,7 +697,7 @@ const lua_rawlen = function(L, idx) {
case CT.LUA_TLNGSTR:
return o.vslen();
case CT.LUA_TUSERDATA:
- return o.len;
+ return o.value.len;
case CT.LUA_TTABLE:
return ltable.luaH_getn(o.value);
default:
@@ -716,7 +716,8 @@ const lua_tointeger = function(L, idx) {
};
const lua_tonumber = function(L, idx) {
- return lvm.tonumber(index2addr(L, idx));
+ let n = lvm.tonumber(index2addr(L, idx));
+ return n === false ? 0 : n;
};
const lua_touserdata = function(L, idx) {