Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior from arrays #78

Open
itz-coffee opened this issue May 6, 2023 · 2 comments
Open

Unexpected behavior from arrays #78

itz-coffee opened this issue May 6, 2023 · 2 comments

Comments

@itz-coffee
Copy link

itz-coffee commented May 6, 2023

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
@ceifa
Copy link
Owner

ceifa commented May 7, 2023

Checked and it only happens if enableProxy is true, I'm not sure if this is a bug

@sirrobindoger
Copy link

Why not add some documentation on that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants