Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False Warning of Function Parameter Count #1204

Closed
MikuAuahDark opened this issue Jun 14, 2022 · 0 comments
Closed

False Warning of Function Parameter Count #1204

MikuAuahDark opened this issue Jun 14, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@MikuAuahDark
Copy link

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

@sumneko sumneko added the bug Something isn't working label Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants