lua502/test/undefined.lua
2020-02-25 05:09:07 +02:00

9 lines
205 B
Lua

-- catch "undefined" global variables
local f=function (t,i) error("undefined global variable `"..i.."'",2) end
setmetatable(getfenv(),{__index=f})
-- an example
a=1
c=3
print(a,b,c) -- `b' is undefined