lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Wed, Jan 19, 2022 at 7:23 AM Patrick Kurth <p.kurth@posteo.de> wrote:
[...]
local source = "rawset(_ENV, 'foo', function() print('bar') end);
foo()"

local chunk = load(source, "@a_chunk", "t", proxy)

chunk() -- prints 'bar'

env.foo() -- prints 'foo' if proxy ~= env, 'bar' if proxy == env

The original post mentioned Lua 5.1.5 so this does not work. _ENV is not a thing in Lua 5.1 if I remember correctly.

--