LuaLS / LuaLS/lua-language-server
Invalid type diagnostic doesn't show when passing value from array directly to a function
未关闭
还没有人认领这个 Issue。
enhancement
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
How are you using the lua-language-server?
Other
Which OS are you using?
Linux
What is the issue affecting?
Type Checking, Diagnostics/Syntax Checking
Expected Behaviour
When using a value from an array as a parameter I expect type checking to work.
Actual Behaviour
Type checking only works when I assign the value from the array to a temporary variable, not when passing it to a function directly.
Reproduction steps
This doesn't show a warning:
---@param num integer
function receive(num)
end
---@type (integer?)[]
local values = {}
receive(values[1])
This works:
local value = values[1]
receive(value) -- Cannot assign `integer?` to parameter `integer`.
Additional Notes
No response
Log File
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
未指定源文件或测试。首先重现这两个 Lua 代码片段,并跟踪直接数组索引参数与临时变量的类型检查诊断路径;当直接调用报告相同的 integer? 到 integer 不匹配时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100