Skip to content

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

@jnbooth

Description

@jnbooth

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions