Module std.strict

Checks uses of undeclared global variables.

All global variables must be 'declared' through a regular assignment (even assigning `nil` will do) in a top-level chunk before being used anywhere or assigned to inside a function.

To use this module, just require it near the start of your program.

From Lua distribution (`etc/strict.lua`).

Functions

__index (t, n) Detect dereference of undeclared global.
__newindex (t, n, v) Detect assignment to undeclared global.


Functions

Methods
__index (t, n)
Detect dereference of undeclared global.

Parameters:

  • t table `_G`
  • n string name of the variable being dereferenced
__newindex (t, n, v)
Detect assignment to undeclared global.

Parameters:

  • t table `_G`
  • n string name of the variable being declared
  • v initial value of the variable
generated by LDoc 1.5.0 Last updated 2026-07-25 13:31:42