Open morrisonlevi opened 3 years ago
Hey @morrisonlevi, can you reproduce the issue on https://psalm.dev ?
For pure functions you already have that out of the box: https://psalm.dev/r/28c64e855b
And impure function could be called for their side-effects.
I found these snippets:
Just because a function is impure doesn't mean the result should be ignored. This is why an attribute like ones that exist in Rust or GCC are useful.
Mind providing an example where this would be useful?
Other languages have this.
__attribute__ ((warn_unused_result))
#[must_use]
We would need to pin down a name, and ideally co-ordinate with other static analysis tools so it isn't quite so tool specific.
Motivating cases are when you return some sort of status object, which commonly will have error cases. Most recently I had a function that was returning an optional error
?ExportError
and callers which ignore this result are inherently buggy.