LuaLS / LuaLS/lua-language-server

Better support for varargs in functions in classes declared with @field

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

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

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

説明

I ran into a minor problem with how vararg is handled in function declarations in an field annotation when the function declaration itself later explicitly lists the arguments.

---@class Handler
---@field ReceiveMsg fun(self: Handler, type: number, ...: string)
local handler = {}

function handler:ReceiveMsg(arg1, arg2, arg3, arg4)
 --- arg2 is inferred as string, but arg3 and arg4 are "any"
end

Why do I even have this mismatch between field and function declaration? The field annotation comes from a library and is an event handler -- the number of parameters depend on a lot of things, but for a given implementation you usually only care about a few that you explicitly declare.

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

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

はじめの一歩

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

調査の方向性

まず、@field ReceiveMsg vararg アノテーションと明示的なメソッド宣言を使って、issue の Handler 例を再現します。関数宣言とパラメータ推論の間で vararg 型がどのように伝播するかを追跡します。完了条件は、arg2、arg3、arg4 が一貫して string として推論され、後続の引数が any のままにならないことです。

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

評価

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

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

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