Closed yhslai closed 1 year ago
The ---@return
tag ought to be applied to local or table method function declarations/assignments and pertains to the return type only e.g.
---@return number
local function test1()
return "1"
end
If you're trying to specify a return type, where the return type is a function you'd do:
---@return fun(): number
local function test2()
return function()
return "1"
end
end
Alternatively, if you do want to specify the intended return type inline, you can do so with a ---@type
for the return
statement e.g.
local test3 = function()
---@type fun(): number
return function()
return "1"
end
end
Basically, the @return
tag shouldn't appear on return
statements, rather it's used to specify the return type of the associated function definition.
Environment
JetBrains Rider 2023.1.3 on Windows 10
Preferences
Lua
Name | Setting
Lua 5.4
Type Safety
Strict nil checks | ☑️ Unknown type (any) is indexable | ☑️ Unknown type (any) is callabale | ☑️
What are the steps to reproduce this issue?
What happens?
No warning or error.
What were you expecting to happen?
Warning or error telling me I'm returning a
fun(): string
instead offun(): number
Any other comments?
Doesn't work either.