LuaLS / LuaLS/lua-language-server
An annotation for indicating that a function may error
還沒有人認領這個 Issue。
- 主要語言
- Lua
- 星號
- 4.4k
- 分支
- 442
- PR 合併指標
- 30 天內沒有已合併 PR
描述
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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先檢視語言伺服器目前如何處理相關的 @noreturn 註解,以及如何分析 pcall 的使用情況。該 issue 沒有指定檔案或測試,而且預期的警告行為被描述為可選,因此在開始撰寫程式碼之前,需要釐清實作範圍和完成標準。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- lua
- 領域
- devtools
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100