LuaLS / LuaLS/lua-language-server

vararg overload issue

Open
#2,277 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

If you have a function which takes in only a vararg and you only overload it, the input type is as expected just each of the overloads:

---@overload fun(param1: "test", param2: string)
---@overload fun(param1: "test2", param2: number)
---@overload fun(param1: "test3", param2: boolean, param3: number)
local function test(...)
end

test()
Screenshot_2

However, if you have a param before the vararg, the input type always becomes param, ...any:

---@overload fun(param1: "test", param2: string)
---@overload fun(param1: "test2", param2: number)
---@overload fun(param1: "test3", param2: boolean, param3: number)
local function test(param1, ...)
end

test()
Screenshot_3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing both annotated Lua examples from the issue and compare the inferred signatures for the two vararg forms. Trace the overload and vararg type-handling entry points, then verify that the parameter-before-vararg case preserves the overload-specific parameter types rather than collapsing to ...any.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.