LuaLS / LuaLS/lua-language-server
feature request: attach a `reason` parameter to `@nodiscard`
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ả
[!NOTE]
I couldn't find an issue for this. sorry if there's a duplicate.
I propose updating the @nodiscard annotation to add a "reason" as to why not discard the value:
---@nodiscard [<reason>]
this would mirror Rust's #[must_use = "reason"] annotation.
example:
---Creates a new class that inherits from this one.
---@return Class
---@nodiscard This method returns the new class; it's pointless to immediately discard it.
function Object:extend()
-- ...
end
discarding the output would then display the warning:
* [warning][Lua Diagnostics.][discard-returns]
The return values of this function cannot be discarded:
This method returns the new class; it's pointless to immediately discard it.
note the colon at the end of "discarded".
if not given a reason, it would fall-back to the usual message, with "discarded" ending with a dot and no further explanation
(yes, I'm aware that reason in the Object:extend example isn't exactly... professional 😅)
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
Không có tệp hoặc bài kiểm thử nào được nêu tên. Hãy bắt đầu bằng cách xác định trình phân tích cú pháp chú thích @nodiscard và chẩn đoán discard-returns, sau đó lần theo cách văn bản chú thích đi đến cảnh báo đó. Hoàn tất khi lý do được cung cấp được hiển thị với dấu hai chấm được yêu cầu, còn khi bỏ qua lý do thì thông báo và dấu chấm hiện có được giữ nguyê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
- Tính năng
- Độ 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