mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 14:25:44 +08:00
Document the duplicate function lint (#26)
This commit is contained in:
parent
149e687d73
commit
bf63d29c9a
@ -237,10 +237,28 @@ print({
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
```lua
|
||||
local foo
|
||||
|
||||
if foo then -- Variable 'foo' defined at line 1 is never initialized or assigned; initialize with 'nil' to silence
|
||||
print(foo)
|
||||
end
|
||||
```
|
||||
|
||||
## DuplicateFunction (21)
|
||||
|
||||
This warning is emitted when a script defines two functions with the same name in the same scope.
|
||||
|
||||
The warning is not produced when the functions are defined in different scopes because this is much more likely to be intentional.
|
||||
|
||||
```lua
|
||||
function foo() end
|
||||
function foo() end -- Duplicate function definition: 'foo' also defined on line 1
|
||||
|
||||
-- OK: the functions are not defined in the same scope.
|
||||
if x then
|
||||
function bar() end
|
||||
else
|
||||
function bar() end
|
||||
end
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user