Open
Description
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