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

coroutine.wrap has wrong return type / leads to false diagnostic warnings #1461

Closed
mfussenegger opened this issue Aug 11, 2022 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@mfussenegger
Copy link

mfussenegger commented Aug 11, 2022

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Linux

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

No warnings reported

Actual Behaviour

Language server publishes diagnostics with a warning with message "This function expects a maximum of 0 argument(s) but instead it is receiving 1."

Reproduction steps

Create a lua file with:

local f = coroutine.wrap(function()
  local x = coroutine.yield()
  print(x)
end)
f()
f(20)

It reports a warning for f(20) stating that the function doesn't take any arguments.

It looks like coroutine.wrap has the wrong return type:

function coroutine.wrap(f: fun())
  -> fun()
─────────────────────────────────────────────────────────────────────────
Creates a new coroutine, with body `f`; `f` must be a function. Returns a
function that resumes the coroutine each time it is called.

[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-coroutine.wrap)

From the reference:

Creates a new coroutine, with body f. f must be a Lua function. Returns a
function that resumes the coroutine each time it is called. Any arguments
passed to the function behave as the extra arguments to resume. Returns the
same values returned by resume, except the first boolean. In case of error,
propagates the error.

The important part is this:

Any arguments passed to the function behave as the extra arguments to resume

The same is the case in Lua 5.4: http://www.lua.org/manual/5.4/manual.html#6.2

Additional Notes

No response

Log File

No response

@sumneko sumneko added the bug Something isn't working label Aug 11, 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