If I have a Lua function f
I can look at all the upvalues in f
's closure by using the debug.getupvalue
function. Similarly if I have a file foo.lua
I can look at the upvalues by first doing foo = loadfile(foo)
then using debug.getupvalue
in the same way that you would for f
. If I require
foo.lua
is there anyway I can figure out what the upvalues for the closure of foo.lua
are?
The module loaded by require
is not preserved by require
's standard loaders. Only the return value from the execution of that module is preserved.
So while you can inspect any upvalues for any function exported by the module, you cannot inspect upvalues that are only accessed by non-accessible functions.