LuaLS / LuaLS/lua-language-server
generic param no hint
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?
Completion
### Expected Behaviour
```lua
---删除物品
---@class pb.S2C_DelItem
---@field itemId integer 物品id
---发送协议到客户端
---@generic T
---@param cmd pb.`T` 命令名
---@param args T
---@return T
function sendToClient(cmd, args)
return nil
end
local ret = sendToClient("S2C_DelItem",{
itemId = 1, -- 无法推断出args为pb.S2C_DelItem类型,输入itemId无字段类型提示
})
ret.itemId -- 返回值能推断出为pb.S2C_DelItem类型,输入itemId有字段类型提示
```


### Actual Behaviour
能正确推断出泛型参数类型并有代码提示
### Reproduction steps
如上代码
### Additional Notes
_No response_
### Log File
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generic inference and completion behavior exercised by the sendToClient example in the issue. Reproduce it in the Lua language server with the provided code, then verify that the args table receives pb.S2C_DelItem field hints while the returned value retains its inferred fields.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100