LuaLS / LuaLS/lua-language-server

Detect functions that never return (and @noreturn annotation)

オープン
#1,881 コメント 4 件 リアクション 5 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Issue ではファイルもテストも指定されていません。まず nil チェックの警告と既存の @nodiscard アノテーション処理を追跡し、次に戻り値を返さない built-in、カスタム関数、@noreturn をどのように表現すべきかを判断してください。例で警告が出なくなり、アノテーションの動作がカバーされていれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
lua
領域
devtools
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。