LuaLS / LuaLS/lua-language-server
Hover preview incorrectly narrows union of literal and type
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Lua
- Star
- 4.4k
- Fork
- 442
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
### 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_
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện vấn đề trong một tệp Lua được mở trong extension Visual Studio Code bằng cách di chuột qua các alias và biến được hiển thị trong báo cáo. Theo dõi đường dẫn kết xuất kiểu khi hover đối với các union kết hợp các giá trị literal với integer hoặc string, và xác minh rằng các bản xem trước vẫn giữ kiểu tổng thể cùng với các thành viên literal.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- lua
- Lĩnh vực
- tooling
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100