4
local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget
6
local mt = getmetatable(_G)
14
local function what ()
15
local d = getinfo(3, "S")
16
return d and d.what or "C"
19
mt.__newindex = function (t, n, v)
20
if not mt.__declared[n] then
22
if w ~= "main" and w ~= "C" then
23
error("assign to undeclared variable '"..n.."'", 2)
25
mt.__declared[n] = true
30
mt.__index = function (t, n)
31
if not mt.__declared[n] and what() ~= "C" then
32
error("variable '"..n.."' is not declared", 2)