LuaLS / LuaLS/lua-language-server
feature request: attach a `reason` parameter to `@nodiscard`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Lua
- Sterne
- 4.4k
- Forks
- 442
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
[!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 😅)
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Es ist keine Datei und kein Test benannt. Beginne damit, den @nodiscard-Annotation-Parser und die discard-returns-Diagnostic zu finden, und verfolge dann, wie der Annotationstext diese Warnung erreicht. Erledigt ist es, wenn ein angegebener Grund mit der angeforderten Doppelpunktsetzung angezeigt wird, während ein ausgelassener Grund die bestehende Meldung und den Punkt beibehält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- lua
- Bereich
- devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100