The checkglobals module + patch (from LuaPowerPatches -- Download Patch for Lua 5.1.3 is a hybrid of a compile-time and run-time approach for detecting undefined variables. Consider the following trivial Lua module:
-- multiplybyx.lua
local function multiplybyx(y)
return y * X -- is X defined???
end
return multiplybyx