summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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;