LuaLS / LuaLS/lua-language-server
Detect functions that never return (and @noreturn annotation)
未關閉
還沒有人認領這個 Issue。
enhancement
- 主要語言
- Lua
- 星號
- 4.4k
- 分支
- 442
- PR 合併指標
- 30 天內沒有已合併 PR
描述
Some functions, such as error, never return control to the caller. This can be used to prove that a value is not nil, for example:
function my_function(input)
local value = input.value or error('Missing value')
-- The following line would currently raise a "Needs nil check" warning
-- However, if it was nil at runtime, an error would have been raised and it would never get this far.
return value:sub(1, 3)
end
It's not just error that can cause this, however. A custom function could be written that never returns as well (the most obvious way is that the function unconditionally calls error, but there may be other ways involving coroutines or functions implemented in C). A @noreturn annotation could be used to indicate this, similar to @nodiscard.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
Issue 中沒有指定檔案或測試。首先追蹤 nil 檢查警告以及現有的 @nodiscard 註解處理,然後確定應如何表示不返回的內建函式、自訂函式和 @noreturn;當範例不再發出警告且註解行為得到涵蓋時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- lua
- 領域
- devtools
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100