How can undefined variable access be caught in Lua?
By default, an unknown variable is looked up in the global or module table and its value will be nil. This is a valid value for a variable, so mistyping a variable name can have interesting results, even if we were avoiding using globals like good boys and girls. There are several approaches for enforcing some strictness with globals. The easiest is to check dynamically whether a given global variable has been initialized explicitly or not; that is, even if it has been set to nil somewhere (see strict.lua in the etc directory of the Lua distribution.) The tests/globals.lua file in the distribution takes another approach, which is to pipe the bytecode listing of the compiler luac through grep, looking for any global access, but it’s only useful if you ‘avoid globals like the plague’. In particular, there are global functions and tables provided by the standard libraries. lua-checker is a lint-like code checking tool.
By default, an unknown variable is looked up in the global or module table and its value will be nil. This is a valid value for a variable, so mistyping a variable name can have interesting results, even if we were avoiding using globals like good boys and girls. There are several approaches for enforcing some strictness with globals. The easiest is to check dynamically whether a given global variable has been initialised explicitly or not; that is, even if it has been set to nil somewhere (see strict.lua in the etc directory of the Lua distribution.) The tests/globals.lua file in the distribution takes another approach, which is to pipe the bytecode listing of the compiler luac through grep, looking for any global access, but it’s only useful if you ‘avoid globals like the plague’. In particular, there are global functions and tables provided by the standard libraries. lua-checker is a lint-like code checking tool. LuaInspect provides real-time source code analysis for Lua using a [Sc