Difference between pages "Module:No globals" and "Module:No globals/sandbox"

(Difference between pages)
Jump to navigation Jump to search
Page 1
Page 2
m (Changed protection settings for "Module:No globals": High-risk template or module (more info) ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
 
(Create sandbox version of Module:No globals)
Tags: Mobile edit Mobile web edit
 
Line 2: Line 2:
 
function mt.__index (t, k)
 
function mt.__index (t, k)
 
if k ~= 'arg' then
 
if k ~= 'arg' then
  +
error('Tried to read nil global ' .. tostring(k), 2)
-- perf optimization here and below: do not load Module:TNT unless there is an error
 
error(require('Module:TNT').format('I18n/No globals', 'err-read', tostring(k)), 2)
 
 
end
 
end
 
return nil
 
return nil
Line 9: Line 8:
 
function mt.__newindex(t, k, v)
 
function mt.__newindex(t, k, v)
 
if k ~= 'arg' then
 
if k ~= 'arg' then
error(require('Module:TNT').format('I18n/No globals', 'err-write', tostring(k)), 2)
+
error('Tried to write global ' .. tostring(k), 2)
 
end
 
end
 
rawset(t, k, v)
 
rawset(t, k, v)