lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Add a shortcut annotation for adding a `nil,string` return type to functions (`@error`)

Open piotrp opened this issue 6 months ago • 4 comments

Returning of errors from Lua functions is often done by returning nil + error message (nil,string):

---@return table
---@overload fun(): nil, string
local function doSomething()

but this syntax can get complex when function takes parameters, or has other overloads. An old solution from LDoc was to use a @error annotation - I propose to add something similar to LuaLS.

piotrp avatar Apr 17 '25 15:04 piotrp