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

Question: how to make arguments be seens as arguments and not return types when a function is passed into another function? #1609

Closed
PerMalmberg opened this issue Oct 3, 2022 · 3 comments

Comments

@PerMalmberg
Copy link

Given this: @field Then fun(self:Task, f:fun(...:any?):any, arg1:any?, ...:any?):Task

how do I make arg1 and ... be seen as additional arguments to the f-function instead of return types of the f-function?

Is there a token I can insert after f:fun(...:any?):any to tell the parser that it has reached the end of the return types for f ?

Also, any plans to make a new release soon for #1556?

@carsakiller
Copy link
Collaborator

I don't think there is any way to force the end of a fun declaration. The fun syntax will hopefully be changed in the future.

You can break it up into two types, though:

---@alias callback fun(...:any): any

---@class Task
---@field Then fun(self: Task, f:callback, arg1: any?, ...:any?):Task

I believe sumneko is currently on vacation, so there will not be a release in the next couple of days, but hopefully when they return 🙂. If you'd like in the meantime, you can unzip the following into your meta/3rd directory.
busted-luassert.zip

@PerMalmberg
Copy link
Author

Ah, thank you. I'll try that this evening.

@PerMalmberg
Copy link
Author

Worked like a charm, thanks again!

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