LuaLS / LuaLS/lua-language-server

False negative: Warnings missing for table length mismatch

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

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

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

説明

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Linux

What is the issue affecting?

Type Checking, Diagnostics/Syntax Checking

Expected Behaviour

In the reproduction code below, f({0}) and f({0, 0, 0}) should issue warnings because they do not match the annotation [integer, integer], which requires a two-element table (tuple).

Actual Behaviour

There are no warnings issued for tables that have an invalid length.

I can see other warnings (e.g., for f("string")), so Neovim and other diagnostics are working correctly.
Screenshot

Reproduction steps

Open a text editor with lua-ls enabled and copy/paste this code.

---@alias Cursor [integer, integer]

---@param c Cursor
local function f(c) end

f("string")

f({ 0 })
f({ 0, 0, 0 })
Additional Notes

I tested with lua-language-server 3.9.1 and 3.13.2 and both have this problem.

Log File

I checked ~/.local/state/nvim/lsp.log since :LspInfo indicates it is the log file, but it was empty.

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

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

はじめの一歩

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

調査の方向性

再現スニペットから始め、テーブルエイリアスに対する lua-language-server の型チェックと診断のパスを確認してください。f("string") に対する既存の警告と、f({ 0 }) および f({ 0, 0, 0 }) に対して不足している警告を比較してください。タプルアノテーションが、テーブルの長さが必要な2要素と異なる場合に診断を報告すれば完了です。

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

評価

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

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

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