Skip to content

overload doesn't seem to match correctly #2509

Closed
@Frityet

Description

@Frityet

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

---@overload fun(x: ffi.cdata*, type: "rvalue"): gccjit.RValue*
---@overload fun(x: ffi.cdata*, type: "lvalue"): gccjit.LValue*
---@overload fun(x: ffi.cdata*, type: "type"): gccjit.Type*
local function expect(x, type)
   ...
end

local rval = expect(data, "rvalue")
--typeof rval should be "gccjit.RValue*"

Actual Behaviour

Screenshot 2024-02-02 at 12 20 34 Type is a union of all return types

Reproduction steps

  1. use this function:
---@overload fun(type: "int"): integer
---@overload fun(type: "str"): string
local function f(type)
   ...
end
  1. use it
local i = f"int"
local s = f"str"

Additional Notes

No response

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