From fc47606d8733d2a3f4e9d5eab970efd58e458836 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Sat, 27 May 2017 09:35:04 +0200 Subject: lua_tonumber should return 0 if value can't be converted to a number --- src/lapi.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/lapi.js') 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) { -- cgit v1.2.3-54-g00ecf