LuaLS / LuaLS/lua-language-server
[Feature request] Implicit casts for common conversions
まだ誰も着手していません。
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I got some code for parsing command line flags/user inputs that commonly uses patterns like this
---@return string ...
local function strsplit(str, sep) end
local a, b, c = strsplit(userinput, ",")
b = tonumber(b) or 0 -- error: This variable is defined as type `string`. Cannot convert its type to `number`
The fix is to define b as string|number in the declaration, but it's a bit cumbersome, especially if I just want b as a number:
local a,
---@type number|string
b, c = strsplit(userinput, ",")
So it would be nice if common type conversion patterns like this could be recognized automatically and either allow the cast or infer the type as string|number from the beginning.
Edit: See comment below, the implicit cast is already happening, this is really about type inference based on later assignments. Which may or may not be a good idea.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、issue に記載されている既存の implicit-cast と type-inference の挙動を追跡します。特に、後続の代入が以前の変数宣言にどのような影響を与えるかを確認します。意図する推論ルールを定義し、コマンドライン解析の例に照らして検証します。合意された挙動が定まり、その結果推論される型をカバーするテストがあれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100