struct S { // S is never used. Why no warning? var x = 1 // // x is never mutated. Why no warning? }
The reason you get no warning for var x = 1
inside the declaration of the struct S is because you could do var s1 = S(); s1.x = 2
You could argue that there should be a warning about S
never being used, but as you say that is heading into linter territory.
My head cannon for why the var is never mutated
warning exists is because it goes to the core of one of Swift's safety goals of preferring immutability. It really doesn't bother me TBH.