lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Incorrect types used for overloaded class when passed as argument

Open NathanSnail opened this issue 3 months ago • 0 comments

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Linux

What is the issue affecting?

Type Checking

Expected Behaviour

When a class which is overloaded as a function, if that class is passed as an argument to another function it should be checked as if it is a function if the argument has a function type.

---@param f function
local function call(f) f() end

---@class foo
---@overload fun()
local something = setmetatable({}, {__call = function () end})

call(something) -- <-- Here something should be treated as `fun()`

Actual Behaviour

The type of the class is treated as foo|fun() which results in a warning because foo does not match function.

Reproduction steps

  1. Create a class with an overload
  2. Pass it to another function which takes a function argument
  3. Observe that a warning is produced

Additional Notes

No response

Log File

No response

NathanSnail avatar Sep 28 '25 06:09 NathanSnail