lua-users home
lua-l archive

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


If this variable is free, then it will be compiled as _ENV['someundefined_func']. Therefore using the __index metamethod on the environment table it would in theory be possible to detect this lookup when it happens. If this variable is local (defined but perhaps incorrectly so) then you'd have to use the debug library to inspect captured variables. 

If you have a function object it is possible to determine its arity using the debug library, although this is considered a bad idea because it is slow. This cannot help with you example but I thought I'd mention it for completeness.

Lua has no support for the metaprogramming required to enumerate bound/free variables from a compiled chunk without executing it and nothing at all to tell you in what context that unbound variable appears. I think a static analysis library could provide an API for that potentially (although determining what is bound in a lua chunk definitely a non trivial thing).