LuaLS / LuaLS/lua-language-server

Initializing a table doesn't satisfied `need-check-nil`

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

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

feat/diagnostics
主要言語
Lua
スター
4.4k
フォーク
442
PR マージ指標
30日以内にマージされた PR はありません

説明

Issue Description

Hi!

I have a code that looks something like this:

---@param t? table
function api.f(t)
	t = type(t) == "table" and t or {}
	t.x = t.x or {} --warning is raised but t can never be nil here because it is set to {} if it was but diagnostics fail to see that
	--etc.
end

Nil checks are not required here because t should never be nil, the preceding lines redefines it as an empty table if it was nil or invalid so the reference should always exist when trying to check if x exists within the table.

I have seen similar reports but I'm not sure if this exact case has been reported or not. I couldn't find a match or I failed to recognize it.

Additional Notes

No response

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

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

はじめの一歩

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

調査の方向性

ソースファイルやテストは指定されていません。まず Lua の例を再現し、警告 need-check-nil の nil チェック診断を追跡してください。t がテーブルに正規化された後、t.x に対して警告が報告されなければ完了です。

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

評価

技術スタック
lua
領域
devtools
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

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

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