LuaLS / LuaLS/lua-language-server
Missing diagnostic when calling a non-function value
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?
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:
```lua
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:
```lua
---@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_
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 đề 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.
Đánh giá
- Công nghệ
- lua
- Lĩnh vực
- devtools
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 65/100