Skip to content

Returning generics with T<X, Y> #1000

Description

@Cassolette

Below, I have a generic list that uses fluid interface to return itself for some methods:

--- @classListlocalList= {}
--- @genericT:List,V,_--- @paramselfT<V, _>--- @paramvalueV # Element value to insert--- @returnT<V, _> # Returning itself (a generic)functionList:insert(value)
returnself-- Returning itself (a generic)end-- test---@typeList<number, nil>localmylistlocaltestingType=mylist:insert(1)
-- ^ Testing type is not `List<number, nil>` but literally `T<V, _>`

image

Expected behavior
testingType is of type List<number, nil>

I am thinking that this case could be something to look at for the 3.0 update.

(Edit: perfect #1000th issue...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeat/LuaCats AnnotationsRelated to Lua Language Server Annotations (LuaCats)feat/genericRelated to generic emulation feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions