-
-
Notifications
You must be signed in to change notification settings - Fork 391
Open
Description
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()
-- ...
enddiscarding 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 😅)
Metadata
Metadata
Assignees
Labels
No labels