LuaLS / LuaLS/lua-language-server

Nil access check does not run

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

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

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

説明

How are you using the lua-language-server?

Other

Which OS are you using?

Linux

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

I have the minimal example

---@class A
---@field b fun(self: A): table?

---@return A[]
local function get_A()
  local l = {}
  for _ = 1, 10 do
    if math.random() > 0.5 then
      table.insert(l, { b = function(self) return { f = 4 } end })
    else
      table.insert(l, { b = function(self) print("hi" .. tostring(self)) end })
    end
  end
  return l
end

local as = get_A()
for i = 1, 10 do
  local a = as[i]
  if a:b().f > 3 then
    print("yo")
  end
end

The lsp should give me an error about a:b().f as a:b() could be nil.

Actual Behaviour

No warnings are shown.

Reproduction steps
  1. Copy the given code into an editor
  2. See that no errors are shown
Additional Notes

No response

Log File

No response

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

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

はじめの一歩

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

調査の方向性

まず、lua-language-server を使用するエディターで最小限の Lua 例を実行し、a:b().f に対して診断が出力されないことを確認します。連鎖呼び出しと nullable な戻り値に対する診断/構文チェックの経路を追跡します。完了条件は、例が a:b() のデリファレンスによって nil 値にアクセスする可能性があると報告し、無関係な警告を導入しないことです。

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

評価

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

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

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