summaryrefslogtreecommitdiff
path: root/src/lcode.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-08 14:53:44 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-08 15:31:48 +1000
commitebf582ea0bb37c92e374b690c2d9ed805dc5b4d6 (patch)
tree4c3e387788b4ed36e61b84301e13e31834b4104d /src/lcode.js
parent97bb7386d33d21b784e21fd4067e77c6c3084d71 (diff)
downloadfengari-ebf582ea0bb37c92e374b690c2d9ed805dc5b4d6.tar.gz
fengari-ebf582ea0bb37c92e374b690c2d9ed805dc5b4d6.tar.bz2
fengari-ebf582ea0bb37c92e374b690c2d9ed805dc5b4d6.zip
src/lcode.js: Fix luaH_set result check
Diffstat (limited to 'src/lcode.js')
-rw-r--r--src/lcode.js7
1 files changed, 4 insertions, 3 deletions
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;