---@class A
---@field b fun(self: A): table?
---@return A[]
local function get_A()
local l = {}
for _ = 1, 10 do
if math.random() > 0.5 then
table.insert(l, { b = function(self) return { f = 4 } end })
else
table.insert(l, { b = function(self) print("hi" .. tostring(self)) end })
end
end
return l
end
local as = get_A()
for i = 1, 10 do
local a = as[i]
if a:b().f > 3 then
print("yo")
end
end
The lsp should give me an error about a:b().f as a:b() could be nil.
How are you using the lua-language-server?
Other
Which OS are you using?
Linux
What is the issue affecting?
Diagnostics/Syntax Checking
Expected Behaviour
I have the minimal example
The lsp should give me an error about
a:b().f
asa:b()
could be nil.Actual Behaviour
No warnings are shown.
Reproduction steps
Additional Notes
No response
Log File
No response