lua-language-server
lua-language-server copied to clipboard
`@overload` return union unexpected behaviour
How are you using the lua-language-server?
NeoVim
Which OS are you using?
Windows
What is the issue affecting?
Type Checking, Diagnostics/Syntax Checking
Expected Behaviour
Type of r1 = EA|0
Not warning: probably nil
Actual Behaviour
Type of r1 = integer|EA|0
Warning: probably nil
Reproduction steps
- Create file
test.lua - Fill
---@enum EA
local EA = {
a = 1,
b = 2,
}
local ab = 0
---@overload fun(): 0
---@overload fun(): EA, [string]
local function fua()
if ab == 0 then
return 0
else
return EA[ab] or EA.a, { "aa" }
end
end
local r1, r2 = fua()
if r1 == 0 then
print(0)
else
print(r2[1])
end
- See type of
r1 - See
Need check nilat line 22
Additional Notes
Maybe duplicate of #1456