lua-language-server
lua-language-server copied to clipboard
Function Prototype Narrowing with nils
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Windows
What is the issue affecting?
Type Checking
Expected Behaviour
Foo.Bar('Baz', 'Qux') -- **string**
Foo.Bar('Baz', nil) -- nil
Foo.Bar('Baz') -- nil
Foo.Bar(nil, 'Qux') -- nil
Foo.Bar(nil, nil) -- nil
Foo.Bar() -- nil
Actual Behaviour
Foo.Bar('Baz', 'Qux') -- **string|nil**
Foo.Bar('Baz', nil) -- nil
Foo.Bar('Baz') -- nil
Foo.Bar(nil, 'Qux') -- nil
Foo.Bar(nil, nil) -- nil
Foo.Bar() -- nil
Reproduction steps
---@param baz string|number
---@param qux string|number
---@return string
---@overload fun(text: string|number, title: nil):nil
---@overload fun(text: nil, title: string|number):nil
---@overload fun(text: nil, title: nil):nil
function Foo.Bar(baz, qux)
if not baz or not qux then
return nil
end
return 'SomeString'
end
Additional Notes
It seems to match the 'strings' can be nil
First input example
Last input example
Log File
No response