Module:No globals
Jump to navigation
Jump to search
This template is currently being deleted. This template is being removed from the pages on which it is currently used, according to the specific instructions at Wikipedia:Templates for discussion/Holding cell, after which it will be deleted. Please do not use it on any additional pages, but do not remove it from pages if it is under deletion review. The decision to delete this template was made following this discussion initiated on 29 October 2022 at Templates for discussion. Administrators: Please review this template's instructions at Wikipedia:Templates for discussion/Holding cell before proceeding with any action. |
This Lua module is used on approximately 126,000 pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
Module:No globals is deprecated. Please see mw:Extension:Scribunto/Lua reference manual#Strict library instead. |
The functionality this module provides was added to Scribunto itself (see T209310) and should now be used as <syntaxhighlight lang="lua" inline="1">require('strict')</syntaxhighlight>.
See also
- Module:Log globals – adds all nil global reads/writes to the Lua log
local mt = getmetatable(_G) or {} function mt.__index (t, k) if k ~= 'arg' then error('Tried to read nil global ' .. tostring(k), 2) end return nil end function mt.__newindex(t, k, v) if k ~= 'arg' then error('Tried to write global ' .. tostring(k), 2) end rawset(t, k, v) end setmetatable(_G, mt)