useless_format
Finds tprint("%", s) or sprint("%", s) with a string s, which only copies it.
Category complexity, warn by default.
#import "Basic";
greeting :: (name: string) -> string {
return tprint("%", name);
}
main :: () {
print("%\n", greeting("Ada"));
}warning[useless_format]: `tprint("%", name)` only copies a string
--> example.jai:4:12
|
4 | return tprint("%", name);
| ^^^^^^^^^^^^^^^^^
|
help: use the string itself, or `copy_string` for a copy you own
|
4 ~ return name;
|
= note: `useless_format` is `warn` by default#import "Basic";
greeting :: (name: string) -> string {
return name;
}
main :: () {
print("%\n", greeting("Ada"));
}Fires on a call of a procedure noted @FormatsToString (the library's tprint and sprint) whose format is exactly "%" and whose single value is a string.