LuaLS / LuaLS/lua-language-server
Function overloading by declaring multiple functions with same name appears to be completely broken
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
- Paste the above code into a file
- Hover over the last line (
DoSomething("test")) - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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