|
Both the f and the g are being optimized in those examples. Note how
the f function uses the LOADK instruction instead of GETUPVAL.
The `local a <const> = 1` in your original program is also optimized,
transforming the `a == 1` into `1 == 1`. However, Lua doesn't optimize
the `1 == 1` as you would expect. That's a separate problem that is
unrelated to the constant variables.