| 此模块被引用於約2,080,000個頁面。 為了避免造成大規模的影響,所有對此模块的編輯應先於沙盒或測試樣例上測試。 測試後無誤的版本可以一次性地加入此模块中,但是修改前請務必於討論頁發起討論。
模板引用數量會自動更新。 |
本模块将读取空全域变量和写入
全局变量视为错误。要使用本模块,在模块上方添加
require('Module:No globals')
即可。排除
arg变量是因为让 Scribunto
require功能正确运行是必要的。(
在此参阅 Scribunto 代码。)
local mt = getmetatable(_G) or {}
function mt.__index (t, k)
if k ~= 'arg' then
error('尝试读取空全局变量:' .. tostring(k), 2)
end
return nil
end
function mt.__newindex(t, k, v)
if k ~= 'arg' then
error('尝试写入全局变量:' .. tostring(k), 2)
end
rawset(t, k, v)
end
setmetatable(_G, mt)