Esc

self_assignment

Finds a value assigned to itself (x = x;).

Category suspicious, warn by default.

Example
#import "Basic";

Size :: struct {
    width: int;
    height: int;
}

set_width :: (size: *Size, width: int) {
    width = width;
}

main :: () {
    s: Size;
    set_width(*s, 4);
    print("%\n", s);
}
Diagnostic
warning[self_assignment]: `width` is assigned to itself
  --> example.jai:9:5
   |
 9 |     width = width;
   |     ^^^^^^^^^^^^^
   |
help: this does nothing; was another value or target meant? (after `using`, both sides name the same field)
   |
 9 -     width = width;
   |
   = note: `self_assignment` is `warn` by default
Fixed
#import "Basic";

Size :: struct {
    width: int;
    height: int;
}

set_width :: (size: *Size, width: int) {
    size.width = width;
}

main :: () {
    s: Size;
    set_width(*s, 4);
    print("%\n", s);
}

Not auto-fixed: the slip may be on the other side.