LuaLS / LuaLS/lua-language-server

Generic attribute constraint doesn't work

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

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

主要言語
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?

Type Checking, Completion

Expected Behaviour

When using the @generic attribute on a method (---@generic T : ClassA) and I have a parameter as type T (---@param item T The item), when I hover over that item parameter I would expect it to list all fields in ClassA

Actual Behaviour

It doesn't list the constrained type's fields. I just see the hover tooltip say: (parameter) item: <T:ClassA>, but none of ClassA's fields are shown

Reproduction steps

Use this code:

---@class ClassA
---@field Name string
---@field Thing string
local ClassA = { Name = "name here", Thing = "thingy"}

---Adds an item
---@generic T: ClassA
---@param item T the Item
function ClassA:AddChild(item)
end

And hover over the item parameter on AddChild, and it won't show any of the fields of ClassA

Additional Notes

No response

Log File

No response

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

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

はじめの一歩

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

調査の方向性

まず ClassA/AddChild の例で問題を再現し、item パラメーターにカーソルを合わせます。次に、型チェックと補完で使用されるジェネリック制約の処理を追跡し、その後、ホバー結果で T に対する ClassA の Name フィールドと Thing フィールドが公開され、制約された型が引き続き正しく報告されることを確認します。

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

評価

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

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

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