LuaLS / LuaLS/lua-language-server

Incorrect type on string-key fields when combined with `[string]`

Đang mở
#3,365 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

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?

Windows

What is the issue affecting?

Type Checking

Expected Behaviour

we have a (generated) class like

---@class GlobalModSettings
---@field ["heat-visualizer-updates-per-surface-per-tick"] ModSetting<int32>
---@field ["nixie-tube-update-speed-alpha"] ModSetting<int32>
---@field ["nixie-tube-update-speed-numeric"] ModSetting<int32>
---@field [string] ModSetting<(int32)|(double)|(boolean)|(string)|(Color)>

which has narrower types for the known entries and a general type for the "everything else" field, but when i then use this type like

local x = settings.global["heat-visualizer-updates-per-surface-per-tick"]

x is given the type from the [string] field, rather than the one that is an exact match for that specific string

Actual Behaviour

(this template is always off screen and i've written the whole thing in the first box...)

Reproduction steps

(this template is always off screen and i've written the whole thing in the first box...)

Additional Notes

No response

Log File

No response

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Không có tệp hoặc bài kiểm thử nào trong repository được nêu tên. Hãy bắt đầu bằng cách tái hiện việc tra cứu GlobalModSettings có chú thích trong Lua language server thông qua Visual Studio Code extension, sau đó lần theo quá trình phân giải kiểu của các trường được lập chỉ mục. Được xem là hoàn thành khi một trường có khóa chuỗi chính xác nhận được kiểu hẹp hơn của nó thay vì kiểu trường [string] rộng hơn.

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
devtools
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 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
38/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.