Update lint.md

Add DeadLocal warning description
This commit is contained in:
Arseny Kapoulkine 2021-01-27 17:34:20 -08:00 committed by GitHub
parent 93f9e5e824
commit 44cdeb07cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -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
```