8000 Unexpected behavior from arrays · Issue #78 · ceifa/wasmoon · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Unexpected behavior from arrays #78
Open
@itz-coffee

Description

@itz-coffee

Adding arrays to the environment leads to unexpected behavior:

  • table.remove will not shift the array
  • Arrays have a length key when using pairs, however ipairs does not have this issue
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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0