LuaLS / LuaLS/lua-language-server
An annotation for indicating that a function may error
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing how the language server currently handles the related @noreturn annotation and how it analyzes pcall usage. The issue does not name files or tests, and the intended warning behavior is described as optional, so the implementation scope and completion criteria need clarification before coding.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100