No globals prevents nil global variables from being written to or read. This module greatly reduces the chance of errors from overriding globals. To use the module, add the following code below your module table definition:
require('Module:No globals')
The require function sets the arg global in the package library when loading a module - see the source code in Scribunto core. To ensure Scribunto can load modules, the arg global is whitelisted.
Documentation[]
Package items[]
getmetatable(_G).__index(t, k)(function)- Read access restriction on
_Gglobal table. - Parameters:
- Error: 'tried to read nil global $k' (line 28; optional)
getmetatable(_G).__newindex(t, k, v)(function)- Write access restriction on
_Gglobal table. - Parameters:
- Error: 'tried to write global $k' (line 42; optional)
Note[]
This module has been adapted as a library in MediaWiki core, called as require('strict').