Esc

excessive_bools

Finds a procedure with more bool parameters than max_bools (default 3).

Category restriction, allow by default.

Off by default; the example is shown with the rule enabled.

Example
#import "Basic";

open :: (path: string, read: bool, write: bool, create: bool, truncate: bool) -> int {
    return path.count;
}

main :: () {
    print("%\n", open("a.txt", true, false, true, false));
}
Diagnostic
warning[excessive_bools]: `open` takes 4 `bool` parameters, past the limit of 3
  --> example.jai:3:1
   |
 3 | open :: (path: string, read: bool, write: bool, create: bool, truncate: bool) -> int {
   | ^^^^
   |
   = help: use an enum or a `#flags` enum so each argument says what it sets, or split the procedure
Fixed
#import "Basic";

Open_Flags :: enum_flags u8 {
    READ;
    WRITE;
    CREATE;
    TRUNCATE;
}

open :: (path: string, flags: Open_Flags) -> int {
    return path.count;
}

main :: () {
    print("%\n", open("a.txt", .READ | .CREATE));
}

A parameter counts when its type is written bool, or it has no type and defaults to true or false.