-- lx-bundle:true

local strict = {}
strict.defined = {}

-- Defines a global variable
function global(t)
	for k, v in pairs(t) do
		strict.defined[k] = true
		rawset(_G, k, v)
	end
end

-- Rejects writes to globals that were not explicitly declared
function strict.__newindex(t, k, v)
	error("cannot set undefined variable: " .. k, 2)
end

-- Rejects reads of globals that were not explicitly declared
function strict.__index(t, k)
	if not strict.defined[k] then
		error("cannot get undefined variable: " .. k, 2)
	end
end

setmetatable(_G, strict)
