Skip to content

False Warning of Function Parameter Count #1204

@MikuAuahDark

Description

@MikuAuahDark

Describe the bug
Function with certain parameters and signatures result in false positive of passing too few arguments to a function.

To Reproduce
Here's a simple Lua code that reproduces the issue.

---@alias FDownloadCallback fun(status: integer, body: string, headers: table<string, string>)
---@alias http_method '"get"'|'"head"'|'"post"'|'"put"'|'"delete"'|'"options"'|'"patch"'
---@alias https_opts {method:http_method,headers:table<string,string>,data:string}

---@param url string
---@param opts https_opts
---@param callback FDownloadCallback
function Request(url, opts, callback)
end

---@return FDownloadCallback
function DecodeJSONResponse(cb, endpoint)
end

-- Note: the whole `Request` function call is highlighted.
Request(
	dest,
	{data = newData, method = data and "post" or "get", headers = newHeaders},
	DecodeJSONResponse(callback, endpoint)
)

I'm getting warning "the function received at least 3 arguments, but got 2." in Request function but as you can see I passed
3 parameters. Weirdly if I put the result of DecodeJSONResponse function then pass that to Request, the issue doesn't occur.

Expected behavior
No warnings.

Screenshots
gambar

Environment (please complete the following information):

  • OS: Windows
  • Is WSL remote? No
  • Client: VSCode

Provide logs
file_d%3A_Data_Development_love-11.3-win64_nlay.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions