[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [5.1.4/newbie] "attempt to index ... 'file' (a nil value)"?
- From: Axel Kittenberger <axkibe@...>
- Date: Fri, 18 Feb 2011 14:53:25 +0100
> BTW, is there a tool that can parse a Lua script to spot syntax
> errors?
Best is to add a metatable to globals _G that errors on index. Put
this on top of your program.
do
local mt = getmetatable(_G) or {}
mt.__index = function(k) error("Global "..k.." does not exist", 2) end
setmetatable(_G, mt)
end
And then just dont code in a way, that globals validly be filled with nil.