LuaLS / LuaLS/lua-language-server
LuaLS processes the wrong LuaDoc for Penlight tablex.filter
オープン
まだ誰も着手していません。
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Windows
What is the issue affecting?
Libraries
Expected Behaviour
local tablex = require("pl.tablex")
tablex.filter(
{},
function() end -- no linting error
)
Actual Behaviour
local tablex = require("pl.tablex")
tablex.filter(
{},
function() end -- Cannot assign `function` to parameter `"()"|"<"|"<="|"=="|">"...(+5)`. (...)
)
Reproduction steps
- Setup LuaLS and copy example code into a .lua file
- Install Penlight using the Addon Manager
Additional Notes
Here's an extract of the LuaDoc. LuaLS seems to always pick the second definition instead of the first one which has the annotations for using a generic function.
---@generic T, A
---@param t T[]
---@param pred fun(val: T, arg: A): any
---@param arg A
---@return T[]
---@nodiscard
function tablex.filter(t, pred, arg) end
---filter an array's values using a predicate function
---@generic T
---@param t T[] -- a list-like table
---@param pred pl.BoolBinOpString -- a boolean function
---@param arg any -- optional argument to be passed as second argument of the predicate
---@return T[]
---@nodiscard
function tablex.filter(t, pred, arg) end
Log File
I set --loglevel=trace and added the code to an empty file while having tail running on the log but there are no relevant details.
$ tail -f ./file_home_function_git_dragdown-modules.log
[13:59:35.741][debug][#0:script/vm/node.lua:490]: clearNodeCache
[13:59:35.741][trace][#0:script/files.lua:286]: Set text: untitled:Untitled-1 takes 0.00012299999999987 sec.
[13:59:35.741][trace][#0:script/files.lua:695]: Compile State: untitled:Untitled-1
[13:59:35.843][debug][#0:script/provider/provider.lua:1120]: textDocument/semanticTokens/range
[13:59:35.857][debug][#0:script/provider/diagnostic.lua:330]: publishDiagnostics untitled:Untitled-1 2
[13:59:40.272][debug][#0:script/vm/node.lua:490]: clearNodeCache
[13:59:40.273][trace][#0:script/files.lua:286]: Set text: untitled:Untitled-1 takes 0.00021399999999971 sec.
[13:59:40.373][trace][#0:script/files.lua:695]: Compile State: untitled:Untitled-1
[13:59:40.374][debug][#0:script/provider/provider.lua:1120]: textDocument/semanticTokens/range
[13:59:40.381][info] [#0:script/provider/diagnostic.lua:171]: clearDiagnostics untitled:Untitled-1
[13:59:47.118][debug][#0:script/vm/node.lua:490]: clearNodeCache
[13:59:47.118][trace][#0:script/files.lua:286]: Set text: untitled:Untitled-1 takes 0.00020199999999981 sec.
[13:59:47.219][trace][#0:script/files.lua:695]: Compile State: untitled:Untitled-1
[13:59:47.220][debug][#0:script/provider/provider.lua:1120]: textDocument/semanticTokens/range
[13:59:47.232][debug][#0:script/provider/diagnostic.lua:330]: publishDiagnostics untitled:Untitled-1 2
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
LuaLS と Penlight addon を使用して VS Code で診断を再現し、その後 library/pl/tablex.lua の 545 行目付近、特に 2 つの tablex.filter の定義を調べます。LuaLS がそれらの定義をどのように解決するかを追跡し、ジェネリックなオーバーロードが選択されることを確認して、例で無効な関数引数が報告されなくなることを検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100