Closed howardpen9 closed 3 weeks ago
I have evaluated options, but it is tricky. In practice we are better to issue a warning of not used return values of an expression, but too many corner cases appears immediately that would make language too strict. I will keep this issue open to figure out what we can do with it later.
Covered in Misti: https://github.com/nowarp/misti/pull/190.
@anton-trunov could we close it or do we need any changes in the compiler as well?
Can you please add here Misti's output for the example from the original post?
contract C {
status_A: Int = 42;
fun test() {
self.status_A == 3; // Bad
self.status_A = 3; // OK
}
}
[MEDIUM] UnusedExpressionResult: Result of evaluation of self.status_A == 3 is unused
sample.tact:4:9:
3 | fun test() {
> 4 | self.status_A == 3; // Bad
^
5 | self.status_A = 3; // OK
Help: Remove the expression or assign its result
See: https://nowarp.io/tools/misti/docs/detectors/UnusedExpressionResult
error Command failed with exit code 1.
The detector will be available in the next release, so here is the actual link to its doc: https://nowarp.io/tools/misti/docs/next/detectors/UnusedExpressionResult
For example: https://t.me/tactlang/2185
The IDE should not accept the value assignment in
==
getting successfully compiled!