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 result when modifying a table (wrong safeenv/optimization) #1535

Open
khvzak opened this issue Nov 17, 2024 · 0 comments
Open

Unexpected result when modifying a table (wrong safeenv/optimization) #1535

khvzak opened this issue Nov 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@khvzak
Copy link
Contributor

khvzak commented Nov 17, 2024

Initially discovered in mlua-rs/mlua#485

Easy to reproduce using Luau cli:

$ luau
> state = {i = 0}
> print("before:", state.i); state.i = state.i + 1; print("after: ", state.i);
before:	0
after: 	0

Setting optimization level to 0 OR removing lua_setsafeenv call will give right result:

❯ luau -O0
> state = {i = 0}
> print("before:", state.i); state.i = state.i + 1; print("after: ", state.i);
before:	0
after: 	1

Luau v0.652

@khvzak khvzak added the bug Something isn't working label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant