LuaLS / LuaLS/lua-language-server

Ability to use specific enum keys as params

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

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

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

説明

It would be nice to be able to use specific enum keys as params. For example today if you try to do something like this:

```
---@enum TestEnum
TestEnum = {
ONE = 1,
TWO = 2,
THREE = 3,
}

---@param test TestEnum.ONE
local function test(test)
end

test(TestEnum.ONE)
test(1)
```

You will get an error:
```
Cannot assign `integer` to parameter `TestEnum.ONE`.
- `integer` cannot match `TestEnum.ONE`
- Type `integer` cannot match `TestEnum.ONE`
- Type `number` cannot match `TestEnum.ONE`
```

Interestingly lls understands that TestEnum.ONE is a real thing just not that it is equal to TestEnum.ONE or 1. For exmaple if you try this:
```
---@enum TestEnum
TestEnum = {
ONE = 1,
TWO = 2,
THREE = 3,
}

---@param test TestEnum.One
local function test(test)
end

test(TestEnum.ONE)
test(1)
```
You will get an error:
```
---@param test TestEnum.NonEnumValue
```

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

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

はじめの一歩

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

調査の方向性

Issue にはファイル、テスト、エントリポイントが特定されていないため、まず lua-language-server で enum 型のチェックとパラメーターの代入可能性の処理を探します。TestEnum.ONE が TestEnum.ONE に対して受け入れられ、その基底値 1 が一貫して処理される一方で、無効な enum キーが引き続き拒否されれば完了です。

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

評価

技術スタック
lua
領域
devtools
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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