Esc

using_pollution

Finds a using of a struct whose members share names with parameters, locals or globals already in scope.

Category pedantic, allow by default.

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

Example
#import "Basic";

Style :: struct {
    count: int;
    color: int;
}

draw :: (count: int, using style: Style) -> int {
    return count + color;
}

main :: () {
    print("%\n", draw(1, .{ 2, 3 }));
}
Diagnostic
warning[using_pollution]: `using style` brings in `count`, which is already in scope
  --> example.jai:8:22
   |
 8 | draw :: (count: int, using style: Style) -> int {
   |                      ^^^^^^^^^^^^^^^^^^
   |
   = help: list the members that are meant (`using,only(...)`) or write `name.member`
Fixed
#import "Basic";

Style :: struct {
    count: int;
    color: int;
}

draw :: (count: int, style: Style) -> int {
    return count + style.color;
}

main :: () {
    print("%\n", draw(1, .{ 2, 3 }));
}

A using x; statement, using x: T; declaration or using parameter whose struct (its own members and those of structs it usings, through a pointer too).