From 44cdeb07cc0f11c107515db396f9aeae2a9c76ae Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 27 Jan 2021 17:34:20 -0800 Subject: [PATCH] Update lint.md Add DeadLocal warning description --- docs/lint.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/lint.md b/docs/lint.md index e6e9fe4..8e71958 100644 --- a/docs/lint.md +++ b/docs/lint.md @@ -228,3 +228,15 @@ print({ first = 3, -- Table field 'first' is a duplicate; previously defined at line 2 }) ``` + +## DeadLocal (20) + +It's easy to forget to initialize a local variable and then proceed to use it regardless. This can happen due to a typo, or sometimes it can happen because the original variable definition is shadowed. When a local variable doesn't have an initial value and is used without ever being assigned to, this warning is emitted: + +``` +local foo + +if foo then -- Variable 'foo' defined at line 1 is never initialized or assigned; initialize with 'nil' to silence + print(foo) +end +```