lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Generic attribute constraint doesn't work

Open AngryCarrot789 opened this issue 7 months ago • 0 comments

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

AngryCarrot789 avatar Nov 29 '23 19:11 AngryCarrot789