Skip to content

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

Open
@khvzak

Description

@khvzak

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions