Update lint.md (#58)

Add documentation for DuplicateLocal
This commit is contained in:
Arseny Kapoulkine 2021-08-04 15:24:25 -07:00 committed by GitHub
parent c42e311bcc
commit 81cddbd82c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -201,9 +201,19 @@ local function find(t, expected)
end
```
## LocalShadowPedantic (17)
## DuplicateLocal (17)
This warning extends `LocalShadow` by also warning about cases where a local variable shadows a local variable with the same name from a parent function, or when it shadows a builtin global. This warning tends to be noisy and as such is disabled by default.
Luau syntax allows to use the same name for different parameters of a function as well as different local variables declared in the same statement. This is error prone, even if it's occasionally useful, so a warning is emitted in cases like this, unless the duplicate name is the placeholder `_`:
```lua
function foo(a, b, a) -- Function parameter 'a' already defined on column 14
end
function obj:method(self) -- Function parameter 'self' already defined implicitly
end
local x, y, x = v:GetComponents() -- Variable 'x' already defined on column 7
```
## FormatString (18)