LuaLS / LuaLS/lua-language-server

Generics, inheritance and an overloaded constructor

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

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

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

説明

VisualStudio Code on Windows, lua-language-server v3.7.4 (Last updated 2024-01-07, 10:29:54)

The following error occurs only when a generic inherits from a type containing an overloaded constructor.

image

local e = Entity()
e:get(Transform2)
e:get(Transform)

The only difference between Transform and Transform2 is the overloaded constructor.

I could "workaround" this issue by removing : ComponentBase from the function Entity:get ... but I want to check whether the given component type is valid.


Here is the simplified annotation file:

---@class ComponentBase

---@class Transform: ComponentBase
Transform = {}

---@class Transform2: ComponentBase
---@overload fun(x: number, y: number): Transform2
Transform2 = {}

---@class Entity
---@overload fun(): Entity
Entity = {}

---@generic T: ComponentBase
---@param type T
---@return T
function Entity:get(type) end

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

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

はじめの一歩

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

調査の方向性

issue にある簡略化されたアノテーションファイルから始め、lua-language-server v3.7.4を使用してWindows上のVisual Studio Codeで診断を再現します。TransformとTransform2に対する汎用的なEntity:get呼び出しを比較し、有効なコンポーネント型が報告されたエラーなしで一貫して処理されることを確認します。

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

評価

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

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

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