Esc

unclosed_resource

Finds a local opened by an @Opens call (file_open, append(*builder, ..)) that nothing closes.

Category suspicious, warn by default.

Example
#import "Basic";
#import "File";

is_readable :: (path: string) -> bool {
    file, ok := file_open(path);
    if !ok return false;

    return true;
}

main :: () {
    print("%\n", is_readable("notes.txt"));
}
Diagnostic
warning[unclosed_resource]: `file` is opened by `file_open` but nothing closes it
  --> example.jai:5:17
   |
 5 |     file, ok := file_open(path);
   |                 ^^^^^^^^^^^^^^^
   |
   = help: close it when done, for example with a `defer` right after opening
   = note: `unclosed_resource` is `warn` by default
Fixed
#import "Basic";
#import "File";

is_readable :: (path: string) -> bool {
    file, ok := file_open(path);
    if !ok return false;
    defer file_close(*file);

    return true;
}

main :: () {
    print("%\n", is_readable("notes.txt"));
}

A local that an @Opens call acquired something for, and that nothing closes.