IntelliJ-Luanalysis
IntelliJ-Luanalysis copied to clipboard
Type casting problem
Hello! I just started using your plugin and I have enough experience in emmylua comments, but I don't know anything about your add-ons yet. Can you help me please to fix just one error here. I have no idea how to do that, it looks like a bug to me:
---@vararg table|function @ `__index` set
---@return table|function... combined `__index`
local function mix_index(...)
local args_num = select("#", ...)
if args_num < 2 then return ... end
local indexes = {} ---@type function[]
local last = 0
for i = 1, args_num do
local index = select(i, ...)
if index then
local t = type(index)
last = last + 1
if t == 'table' then
indexes[last] = function(_, key)
if key == nil then return { index } end
return index[key] -- <<< I DON'T KNOW HOW TO CAST THIS
end
elseif t == 'function' then
indexes[last] = --[[---@type function]] index
end
end
end
return function (_, key)
if key == nil then return indexes end
for _, index in ipairs(indexes) do
local result = index(_, key)
if result ~= nil then return result end
end
end
end
return mix_index