LuaLS / LuaLS/lua-language-server

Infer pcall arguments from the first function parameter

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

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

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

説明

Hi 👋

I was wondering if it would be possible for LuaLS to infer the types of the arguments passed to pcall based on the signature of its first function argument. This would significantly improve developer experience, especially when working with typed Lua (e.g., EmmyLua annotations) or when relying on auto-completion and type checking.

Example:
local function greet(name: string)
  print("Hello, " .. name)
end

pcall(greet, "world") 
             ^- here we should see `name: string`

In this case, it would be great if LuaLS could infer that greet expects a string, and therefore type-check or suggest "world" accordingly when passed to pcall.

Currently, the parameters after the first one are not checked or suggested with much context, making it less ergonomic when using pcall (or other similar functions) for safe calls.

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

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

はじめの一歩

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

調査の方向性

まず、例に示されている pcall の呼び出しを LuaLS がどのように処理し、関数シグネチャに対して引数をどのようにチェックしているかを追跡します。関連する型チェックと補完の経路を特定し、その後、最初の関数パラメーター以降の引数が、型付き Lua 呼び出しに期待されるコンテキストを受け取ることを確認します。

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

評価

技術スタック
lua
領域
developer-experience, devtools
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

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

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