LuaLS / LuaLS/lua-language-server
Hover preview incorrectly narrows union of literal and type
还没有人认领这个 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?
Linux
### What is the issue affecting?
Hover
### Expected Behaviour
```lua
---@alias inttype -1 | 0 | integer
---@type inttype
local intvar = 1
---@alias stringtype "a" | "b" | string
---@type stringtype
local stringvar = "x"
```
I expect the hover previews for `inttype`, `intvar`, `stringtype`, and `stringvar` to show the full expansion of the `intttype` and `stringtype` aliases, something like
```
inttype:
| -1
| 0
| integer
```
and
```
stringtype:
| "a"
| "b"
| string
```
### Actual Behaviour
The rendered preview of the type aliases omits the overall type:
```
inttype:
| -1
| 0
```
and
```
stringtype:
| "a"
| "b"
```
This is especially weird because if those were the actual type definitions then the two assignments in the example would be type errors, which they are not.
### Reproduction steps
Put the code above into a Lua file in vscode with the language server extension running. Hover over the type aliases and the variables. The problem happens with just one literal in each union, two aren't required but I thought they illustrated the preview problem better.
### Additional Notes
The reason I want to make "useless" union types like this is for hinting to humans that those specific values are special in some way.
### Log File
_No response_
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
在 Visual Studio Code 扩展中打开的 Lua 文件里,将鼠标悬停在报告中显示的别名和变量上,以复现该问题。跟踪将字面量值与 integer 或 string 组合的 union 的悬停类型渲染路径,并验证预览是否在保留字面量成员的同时保留整体类型。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100