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

Unable to add a @vararg for functions #61

Closed
pouwelsjochem opened this issue Mar 9, 2021 · 2 comments
Closed

Unable to add a @vararg for functions #61

pouwelsjochem opened this issue Mar 9, 2021 · 2 comments

Comments

@pouwelsjochem
Copy link
Contributor

Environment

name version
IDEA version [e.g. IC2018.2 EAP, CL2018.1.2]
Luanalysis version [e.g. v1.2.5]
OS [e.g. OSX 10.13.4, Windows 10]

What are the steps to reproduce this issue?

---@vararg fun(event:TimerEvent)
---@return fun(event:TimerEvent)
function t.toggle(...)
    return function(event)
        arg[1 + ((event.count - 1) % arg.n)](event)
    end
end

What happens?

I get an error (Unresolved type "fun") on the fun keyword in ---@vararg fun(event:TimerEvent)

What were you expecting to happen?

The ability to define functions as @vararg param

Any other comments?

The @param ... fun(event:TimerEvent) format also doesn't work

@adriweb
Copy link

adriweb commented Mar 9, 2021 via email

@pouwelsjochem
Copy link
Contributor Author

Hmm, the aliasing workaround doesn't give any error, but the caller is unable to detect the parameter type inside of the function (in my example, the caller doesn't know the type of event being TimerEvent)

Currently my own workaround is adding overloads for a reasonable amount of parameters:

---@overload fun(_toggle1:fun(event:TimerEvent)):fun(event:TimerEvent)
---@overload fun(_toggle1:fun(event:TimerEvent), _toggle2:fun(event:TimerEvent)):fun(event:TimerEvent)
---@overload fun(_toggle1:fun(event:TimerEvent), _toggle2:fun(event:TimerEvent), _toggle3:fun(event:TimerEvent)):fun(event:TimerEvent)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants