Open itz-coffee opened 1 year ago
Adding arrays to the environment leads to unexpected behavior:
table.remove
length
pairs
ipairs
const factory = new LuaFactory() const lua = await factory.createEngine() const env = lua.global
env.set("array_test", ["a", "b", "c"]) await lua.doString(` table.remove(array_test, 2)
for k, v in pairs(array_test) do print(k, v) end
`)
0 a 1 c 2 nil length 3
These issues do not happen when creating regular tables ```js await lua.doString(` local table_test = {"a", "b", "c"} table.remove(table_test, 2) for k, v in pairs(table_test) do print(k, v) end `)
1 a 2 c
Checked and it only happens if enableProxy is true, I'm not sure if this is a bug
enableProxy
Why not add some documentation on that?
Adding arrays to the environment leads to unexpected behavior:
table.remove
will not shift the arraylength
key when usingpairs
, howeveripairs
does not have this issueenv.set("array_test", ["a", "b", "c"]) await lua.doString(` table.remove(array_test, 2)
`)
0 a 1 c 2 nil length 3