lua-language-server
lua-language-server copied to clipboard
Custom __pairs expects only 1 return value
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Linux
What is the issue affecting?
Type Checking
Expected Behaviour
I expected no warnings
Actual Behaviour
There is a redundant return value warning
Reproduction steps
Here's an example where string paths are transformed to their package.loaded value
local imports = {
mod1 = "src.mod1",
mod2 = "src.mod2"
}
return setmetatable({}, {
__pairs = function(_)
local iter = pairs(imports)
local newiter = function (table, index)
local k, path = iter(table, index)
return k, package.loaded[path]
end
--- LuaLS is wrong here
---@diagnostic disable-next-line:redundant-return-value
return newiter, imports, nil
end
})
Additional Notes
https://www.lua.org/pil/7.3.html
Log File
No response