lua-language-server
lua-language-server copied to clipboard
An annotation for indicating that a function may error
It would be pretty useful to have an indicator of whether the function may error (and thus needs to be handled with pcall or the like).
---@fallible
---@param bar string
---@return string bar
local function assert_is_foobar(bar)
if bar ~= "foobar" then
error("bar isn't equal to foobar")
end
return bar
end
I'm aware of #1881 but it doesn't fullfill the same purpose as @fallible, the main difference being the fact that @noreturn indicates that the function never returns while this indicates that the function could return an error
The LSP server could also potentially show the user a warning if they don't wrap a @fallible function in a pcall call