LuaLS / LuaLS/lua-language-server

Inheriting from a generic class, which uses an annotated table definition causes fields to get lost

Open
#3,443 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Windows

What is the issue affecting?

Annotations, Type Checking

Expected Behaviour
--- (field) Specific.value: string
hover(t.value)
Actual Behaviour
--- (field) Specific.value: unknown
hover(t.value)
Reproduction steps
---@class GenericSuper<T> : { value: T }

---@class Specific : GenericSuper<string>

---@type Specific
local t

hover(t.value)

Then hover on t.value

Additional Notes

Interestingly this seems to only affect inheriting from table constructor. When converting it into a field, it works as expected:

---@class GenericSuper<T>
---@field value T

---@class Specific : GenericSuper<string>

---@type Specific
local t

--- (field) Specific.value: string
hover(t.value)
Log File

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in NeoVim using the GenericSuper table constructor and the Specific : GenericSuper inheritance shown in the report. Compare hover results for the table-constructor form and the equivalent @field form; done means t.value is inferred as string in the inherited table-constructor case.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.