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

feature: support generics in function type format #1170

Open
TheFireBlast opened this issue May 26, 2022 · 2 comments
Open

feature: support generics in function type format #1170

TheFireBlast opened this issue May 26, 2022 · 2 comments
Labels
enhancement New feature or request feat/generic Related to generic emulation feature feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats)

Comments

@TheFireBlast
Copy link

TheFireBlast commented May 26, 2022

Currently, the only way to document generic functions is to use @generic. and it's not possible to use them in overloads or fields.

The following examples are invalid:

---@generic T
---@param arg1 string
---@param arg2 T
---@return T
---@overload fun(arg2: T) <- Undefined type or alias `T`.
local function foo(arg1, arg2)
    return arg2 or arg1
end
---@class Foo
---@field bar fun<T>(arg:T): T <- `(` expected.
local Foo = {}
@TheFireBlast TheFireBlast changed the title feature: support generic type format feature: support generics in function type format May 26, 2022
@sumneko sumneko added enhancement New feature or request feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats) labels May 26, 2022
@carsakiller carsakiller added the feat/generic Related to generic emulation feature label Jan 30, 2023
@stylpe
Copy link

stylpe commented Mar 21, 2023

#723 seems like it already covers this?

@PoolloverNathan
Copy link

+1, porting Haskell's ReadP to Lua and I need a fun<U>(fun(T): P<U>): P<U>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat/generic Related to generic emulation feature feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats)
Projects
None yet
Development

No branches or pull requests

5 participants
  翻译: