You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nested local _ENV redirection leaks scope (locals.lua:148-154) #284
In the Lua 5.3 suite file locals.lua, the nested lexical-environment block at lines 148-153 fails:
dolocal_ENV= {assert=assert, A=10};
dolocal_ENV= {assert=assert, A=20};
assert(A==20);x=A-- line 150: attempt to call a nil value (global 'assert')endassert(A==10andx==20)
end
At line 150 the free name assert (compiled as _ENV.assert) resolves to nil, even though the innermost _ENV table is {assert=assert, A=20} and the enclosing _ENV.assert is the real assert function.
This is independent of debug.getupvalue/setupvalue and load — the block uses only local _ENV = {table} rebinding and free-name resolution. It surfaced while implementing #256 (which is otherwise complete: lines 71-83 and 144 of locals.lua now pass).
Notes
Context-dependent. Reproducing lines 148-153 in isolation (single- and two-level nesting, with and without a top-level local _ENV = (function(...) return ... end)(_G) rebind) all pass. Only the full accumulated context of locals.lua (lines 1-147, in particular the _ENV = mt / foo block at 137-146) triggers it. This points to a scope/state leak in nested local _ENV redirection rather than a bug in the two-level pattern itself.
Likely lives in lib/lua/compiler/scope.ex / codegen.ex_ENV resolution (see Plan A16 _ENV-as-register-0 design).
Current state
locals.lua is partial-skipped at lines: 148..154 (category: :semantic) in test/lua53_skips.exs. The rest of the file passes. Lift the skip once this is fixed.
Acceptance
Lines 148-154 of locals.lua pass.
Remove the 148..154 partial-skip entry for locals.lua.
A focused unit test reproducing the nested local _ENV scope leak.
Activity