Module:superstrict

local dump = mw.dumpObject local error = error

local new_G = {} new_G.__index = new_G setmetatable(_G, new_G)

for k, v in next, _G do	new_G[k] = v	_G[k] = nil end

function new_G:__index(k) -- `arg` and `_G` are used by `require`. if k == "arg" or k == "_G" then return new_G[k] elseif new_G[k] then error("variable " .. dump(k) .. " is a global", 2) end error("variable " .. dump(k) .. " is not declared", 2) end

function new_G:__newindex(k, v)	if k ~= "arg" then error("assign to undeclared variable " .. dump(k), 2) end new_G[k] = v end