aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-05-27 09:35:04 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-05-27 09:35:04 +0200
commitfc47606d8733d2a3f4e9d5eab970efd58e458836 (patch)
treecfbbdc0c03fb408b562cd0e3bee824cd0bab30b5
parent3984ff6ea092325bcbc8e4b8593e73cce084586a (diff)
downloadfengari-fc47606d8733d2a3f4e9d5eab970efd58e458836.tar.gz
fengari-fc47606d8733d2a3f4e9d5eab970efd58e458836.tar.bz2
fengari-fc47606d8733d2a3f4e9d5eab970efd58e458836.zip
lua_tonumber should return 0 if value can't be converted to a number
-rw-r--r--src/lapi.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 63ed33e..4abe0c2 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -714,7 +714,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) {