-
-
Notifications
You must be signed in to change notification settings - Fork 390
Closed
Labels
documentationHas to do with documentation either in the wiki or in the repoHas to do with documentation either in the wiki or in the repo
Description
Currently, you cannot specify the type (or name) of a variable @return:
---@return ... Description!
---This is not allowed
---@return ... string Description!This problem is more complex than just adding that ability though, take string.match() as an example:
string.match() is defined as returning ..., meaning its returns are marked as unknown. When using the no-unknown diagnostic, this results in a warning/error. In reality, it can only ever return string(s) or nil:
local text = "Key: 123456789"
local match = string.match(text, "Key: (%d+)")
print(match) -- 123456789
local match, match2 = string.match(text, "(Key): (%d+)")
print(match, match2) -- Key, 123456789
local match = string.match(text, "Pass: (%d+)")
print(match) -- nilSo maybe a new syntax should be introduced:
---@return nil|string... match Description!
or
---@return string|nil ... Description!
This would then result in the following:
local match, match2 = string.match(foo, bar)
-- match -> nil | string
-- match2 -> nil | stringMetadata
Metadata
Assignees
Labels
documentationHas to do with documentation either in the wiki or in the repoHas to do with documentation either in the wiki or in the repo