From ebf582ea0bb37c92e374b690c2d9ed805dc5b4d6 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 8 May 2017 14:53:44 +1000 Subject: src/lcode.js: Fix luaH_set result check --- src/lcode.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lcode.js b/src/lcode.js index b697b16..8d903a6 100644 --- a/src/lcode.js +++ b/src/lcode.js @@ -485,10 +485,11 @@ const freeexps = function(fs, e1, e2) { const addk = function(fs, key, v) { let f = fs.f; let idx = ltable.luaH_set(fs.ls.h, key); /* index scanner table */ - if (idx && !idx.ttisnil()) { /* is there an index there? */ + if (idx.ttisinteger()) { /* is there an index there? */ + let k = idx.value; /* correct value? (warning: must distinguish floats from integers!) */ - if (idx.value < fs.nk && f.k[idx.value].ttype() === v.ttype() && f.k[idx.value].value === v.value) - return idx.value; /* reuse index */ + if (k < fs.nk && f.k[k].ttype() === v.ttype() && f.k[k].value === v.value) + return k; /* reuse index */ } /* constant not found; create a new entry */ let k = fs.nk; -- cgit v1.2.3-70-g09d2