LuaLS / LuaLS/lua-language-server

Fields of a generic class can't pass the generic to another generic class

Open
#3,390 0 comments 1 reaction 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?

Linux

What is the issue affecting?

Type Checking

Expected Behaviour
local works = f.a -- type is `number[]`
local doesnt = f.b -- type is `table<string, number>`
local also_doesnt = f.b["hello"] -- type is `number`
Actual Behaviour
local works = f.a -- type is `number[]`
local doesnt = f.b -- type is `table<string, <T>>`
local also_doesnt = f.b["hello"] -- type is `<V>`
Reproduction steps
---@class Foo<T>
---@field a T[]
---@field b table<string, T>

---@type Foo<number>
local f = {}
Additional Notes

No response

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

Start with the Lua reproduction for Foo and inspect how type checking resolves fields a and b when Foo is used. Confirm that the nested table field and indexed value retain number rather than unresolved generic placeholders; done means both reported types match the expected behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.