LuaLS / LuaLS/lua-language-server

An annotation for indicating that a function may error

Open
#2,400 0 comments 3 reactions 0 assignees View on GitHub

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).
```lua
---@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.