LuaLS / LuaLS/lua-language-server

定义泛型函数对于指定了泛型类型的参数插件无法识别该参数的类型,不能提示出该类型的正确成员

Open
#2,634 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?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Annotations

Expected Behaviour

插件应该识别 testfun 函数 参数 p 有 p1 的字段

Actual Behaviour

插件无法识别 testfun 函数 参数 p 有 p1 字段

Reproduction steps

---@class TestTP
---@field p1 string
---@field p2 number

---@generic T: TestTP
---@param p T
function testfun(p)
print(p.p1)
end

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 provided generic-function reproduction and trace annotation and type-inference handling for the constrained type parameter T. Confirm the behavior in the Visual Studio Code extension, then consider the issue done when p.p1 is recognized as a string and its members are correctly suggested.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.