diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-11 15:37:05 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-11 15:37:10 +1000 |
commit | 63b6b09a6cbab4446f42b5b7a8c85e6109cac9f6 (patch) | |
tree | 3c4b092284d583fd6d59bc96045f1c19a987fc08 /src/lvm.js | |
parent | fb1de39c6b9a5812e229aa8ad4f87e594f8ea179 (diff) | |
download | fengari-63b6b09a6cbab4446f42b5b7a8c85e6109cac9f6.tar.gz fengari-63b6b09a6cbab4446f42b5b7a8c85e6109cac9f6.tar.bz2 fengari-63b6b09a6cbab4446f42b5b7a8c85e6109cac9f6.zip |
src/lvm.js: Setting nil should delete from table
Closes #37
Diffstat (limited to 'src/lvm.js')
-rw-r--r-- | src/lvm.js | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1079,7 +1079,10 @@ const settable = function(L, table, key, v, recur) { let element = ltable.luaH_set(table.value, key); if (!element.ttisnil()) { - element.setfrom(v); + if (v.ttisnil()) + ltable.luaH_delete(table.value, key); + else + element.setfrom(v); } else { luaV_finishset(L, table, key, v, element, recur); } @@ -1094,7 +1097,10 @@ const luaV_finishset = function(L, t, key, val, slot, recur) { assert(slot.ttisnil()); tm = ltm.luaT_gettmbyobj(L, t, ltm.TMS.TM_NEWINDEX); // TODO: fasttm if (tm.ttisnil()) { - slot.setfrom(val); + if (val.ttisnil()) + ltable.luaH_delete(t.value, key); + else + slot.setfrom(val); return; } } else { /* not a table; check metamethod */ |