Missing diagnostic when calling a non-function value
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
Tái hiện vấn đề bằng các snippet Lua gọi các giá trị số và chuỗi, sau đó lần theo điểm vào của chẩn đoán hoặc kiểm tra kiểu xử lý các biểu thức gọi. Hoàn thành khi các chẩn đoán được báo cáo cho những giá trị chắc chắn không thể gọi, trong khi các bảng có thể gọi và các giá trị có chữ ký overload hoặc __call rõ ràng vẫn được chấp nhận.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
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?
Diagnostics/Syntax Checking
Expected Behaviour
LuaLS should report a diagnostic when a value whose type is known to be non-callable is called like a function.
For example, calling a number, string, boolean, or a plain table without a known __call / @overload signature should produce a warning/error, because the code will fail at runtime.
Actual Behaviour
No diagnostic is reported.
Even when the value is explicitly annotated or cast as number, LuaLS accepts the call silently.
Reproduction steps
Use the following code:
local x = 1 --[[@as number]]
x()
local y = 1
y()
---@type number
local z = 1
z()
Expected: diagnostics on x(), y(), and z().
Actual: no diagnostics are reported.
At runtime, these calls fail with an error similar to:
attempt to call a number value
Additional Notes
This is different from callable table / __call support.
I am not asking LuaLS to reject values that are explicitly annotated as callable, for example with ---@overload fun(...) or an equivalent __call signature.
The issue is about direct calls to values whose inferred or declared type is definitely not callable, such as number.
This also affects typo detection. For example, code like this can accidentally parse as a function call:
---@param name string
local function greet(name)
return "Hello " .. name "!"
end
Here name "!" is a call expression, but name is a string, so a diagnostic would be useful.
Log File
No response
- Ngôn ngữ chính
- Lua
- Star
- 4.4k
- Fork
- 442
- Merge trung bình
- 8 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 1
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.
Issue khác của LuaLS/lua-language-server
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
LuaLS/lua-language-server#1776 ·
-
泛型for迭代器的类型推导漏掉了带__call的类 Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
LuaLS/lua-language-server#3463 · 5 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
LuaLS/lua-language-server#3461 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
LuaLS/lua-language-server#3460 · 1 bình luận · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
LuaLS/lua-language-server#3459 · 1 reaction ·
Tất cả issue của LuaLS/lua-language-server
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
LandSandBoat/server#11579 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ArchiveTeam/sinavideo-grab#7 · 3 reaction ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
mailcow/mailcow-dockerized#7480 ·
-
Mapper: a failed area image export crashes Mudlet if the profile closed while it was running Đang mởmapper bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100