LuaLS / LuaLS/lua-language-server
Type warning when calling os.time with a table
还没有人认领这个 Issue。
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
### 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?
Type Checking
### Expected Behaviour
No warning
### Actual Behaviour
The following warning is appearing:
Cannot assign `string|osdate` to parameter `osdateparam?`.
- `string` cannot match `osdateparam?`
- Type `string` cannot match `nil`
- Type `string` cannot match `osdateparam`
### Reproduction steps
1. Enter the following code
```
local tDate = os.date("*t", os.time())
-- tDate is a table, e.g. {year=2024, month=1, day=10, hour=13, min=2, sec=24, yday=10, wday=4, isdst=false}
local newTime = os.time(tDate)
```
2. Linter warning appears in the _problems_ tab
### Additional Notes
_No response_
### Log File
_No response_
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 issue 中的 Lua 代码片段在 Visual Studio Code 扩展中重现该警告,重点关注 os.date 和 os.time 调用。跟踪 os.time 使用的类型信息,并验证传递 os.date("*t", os.time()) 返回的表时可以被接受,且不会出现类型检查警告。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100