leaked_temporary
Finds an inferred owned result that is only compared, measured, indexed or printed, so nothing can free it.
Category suspicious, warn by default.
#import "Basic";
is_seven :: (n: int) -> bool {
return sprint("%", n) == "7";
}
main :: () {
print("%\n", is_seven(7));
}warning[leaked_temporary]: the memory `sprint` allocates is only compared and never freed
--> example.jai:4:12
|
4 | return sprint("%", n) == "7";
| ^^^^^^^^^^^^^^
|
= help: keep it in a local and `defer free` it, or use a temporary-storage procedure such as `tprint`
= note: `leaked_temporary` is `warn` by default#import "Basic";
is_seven :: (n: int) -> bool {
return tprint("%", n) == "7";
}
main :: () {
print("%\n", is_seven(7));
}A call of a procedure that allocates its result (sprint, join, copy_string, ...) whose result is used where it is read and dropped at once: an operand of a comparison, the receiver of .count or of an index, or a value argument of a @PrintLike call.