Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Missing diagnostic when calling a non-function value

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

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
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
lua
Lĩnh vực
devtools

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

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.

Issue khác của LuaLS/lua-language-server

Tất cả issue của LuaLS/lua-language-server

Issue tương tự

Thêm issue về Lua

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.