LuaLS / LuaLS/lua-language-server
Exact Class with `__index` Assignment Result in Loss of All Class Methods
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?
Completion, Hover
Expected Behaviour
Method :method and :method2 is shown.
Actual Behaviour
No method is shown.
Reproduction steps
Test code:
---@class (exact) Foo
local Foo = {}
Foo.__index = Foo ---@diagnostic disable-line inject-field
function Foo:method()
end
function Foo:method2(value)
end
---@return Foo
local function foo()
end
local b = foo()
Variable b has type of Foo. However typing b: won't show method and method2. The self variable inside Foo:nethod and Foo:method2 will also have same issue if used.
Removing the (exact) make it work works as expected. Removing the __index assignment also make it works as expected. However, silencing the __index inject field with ---@field __index Foo instead of using ---@diagnostic still result in same issue.
Hovering to b also won't show any of the methods. However hovering to Foo works.
Additional Notes
Typing the method name manually (e.g. :method2) will show completion normally and will make b show method2 after it's used once. But only method2 in that specific case. method still not be shown.
Log File
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 đoạn mã Lua được cung cấp và kiểm tra hành vi hoàn thành cũng như hover đối với các lớp exact có phép gán __index. Sử dụng khác biệt được báo cáo giữa các lớp exact và non-exact làm điểm bắt đầu để so sánh. Được xem là hoàn tất khi các phương thức Foo xuất hiện cho b và self trong phần hoàn thành và hover, mà không yêu cầu phải nhập tên phương thức trước.
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
- 42/100