LuaLS / LuaLS/lua-language-server

Function overloading by declaring multiple functions with same name appears to be completely broken

Open
#3,396 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

MacOS

What is the issue affecting?

Annotations, Type Checking

Expected Behaviour

Given:

---@meta

---@param stringParam string
function DoSomething(stringParam) end

---@param intParam1 integer
---@param intParam2 integer
function DoSomething(intParam1, intParam2) end

DoSomething("test")

I would expect DoSomething("test") to pass typechecking, because it meets the first definition of DoSomething (a single string parameter).

Actual Behaviour

Typechecking fails with "This function requires 2 argument(s) but instead it is receiving 1. (missing-parameter)"

Reproduction steps
  1. Paste the above code into a file
  2. Hover over the last line (DoSomething("test"))
  3. See error
Additional Notes

This issue does not apply to the use of @overload for functions. This passes typechecking:

---@meta

---@param stringParam string
---@overload fun(intParam1: integer, intParam2: integer)
function DoSomething(stringParam) end

DoSomething("test")
Log File

No response

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 the issue with the minimal Lua snippet in the report and compare it with the working @overload example. Trace the type-checking path for repeated function declarations and overload resolution, then verify that the single-argument call passes while the two-argument call remains valid.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.