Esc

push_in_static_if

Finds a scoped push directly in an #if arm, which lasts past the arm.

Category suspicious, warn by default.

Example
#import "Basic";

USE_ARENA :: true;

main :: () {
    arena := context.allocator;

    #if USE_ARENA {
        push_allocator(arena);
    }

    print("%\n", alloc(8) != null);
}
Diagnostic
warning[push_in_static_if]: this push lasts until the end of the enclosing procedure, not the end of the `#if` arm
  --> example.jai:9:9
   |
 9 |         push_allocator(arena);
   |         ^^^^^^^^^^^^^^^^^^^^^
   |
   = help: wrap it and the code it covers in a `{ }` block, or move it out of the `#if`
   = note: `push_in_static_if` is `warn` by default

#if adds no scope, so push_allocator(a); directly in an #if or #else arm lasts to the end of the enclosing block or procedure, not the arm.