dropped_result
Finds a call drops the bool that follows the values it keeps (n := to_integer(s);).
Category suspicious, warn by default.
#import "Basic";
parse :: (text: string) -> int, bool {
if text == "7" return 7, true;
return 0, false;
}
main :: () {
value := parse("x");
print("%\n", value);
}warning[dropped_result]: `parse` returns 2 values but this keeps 1; the next value is a `bool`, which usually says whether the call worked
--> example.jai:9:14
|
9 | value := parse("x");
| ^^^^^^^^^^
|
help: receive the flag, or write `, _` to show it is ignored on purpose
|
9 ~ value, _ := parse("x");
|
= note: `dropped_result` is `warn` by default#import "Basic";
parse :: (text: string) -> int, bool {
if text == "7" return 7, true;
return 0, false;
}
main :: () {
value, ok := parse("x");
if !ok print("not a number\n");
else print("%\n", value);
}A declaration or assignment whose right side is one call that returns more values than the left side names, where the first dropped value, the one right after the last kept, is a bool: value := parse(text); quietly turns a failed parse into 0.