LuaLS / LuaLS/lua-language-server
Better support for varargs in functions in classes declared with @field
还没有人认领这个 Issue。
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
I ran into a minor problem with how vararg is handled in function declarations in an field annotation when the function declaration itself later explicitly lists the arguments.
```
---@class Handler
---@field ReceiveMsg fun(self: Handler, type: number, ...: string)
local handler = {}
function handler:ReceiveMsg(arg1, arg2, arg3, arg4)
--- arg2 is inferred as string, but arg3 and arg4 are "any"
end
```
Why do I even have this mismatch between field and function declaration? The field annotation comes from a library and is an event handler -- the number of parameters depend on a lot of things, but for a given implementation you usually only care about a few that you explicitly declare.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用 @field ReceiveMsg vararg 注解和显式的方法声明复现 issue 的 Handler 示例。跟踪函数声明和参数推断期间 vararg 类型的传播。完成标准是 arg2、arg3 和 arg4 都一致地被推断为 string,而不是让后续参数保留为 any。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100