Check for boolean operations that can be minimized

Motivation

Today I had a bug in my code that the compiler could almost catch for me.

Given that bar and baz are booleans

let foo = !bar && !bar

the expression is equivalent

let foo = !(bar || bar)
let foo = !bar

Okay.

Notice what I did on the first line? I didn't use the baz in the expression I mentioned before. Sometimes we do typos like that which create bugs that can be hard to figure out what we did wrong. It would be productive if we had a warning for that as the expression can be minimized, and once minimized, we can see that they don't make much sense.

Pitch

Introduce a boolean minimization algorithn (e.g. Quine–McCluskey algorithm) to the compiler and offer the result to the programmer

Despite the possibility of such an expression being redundant, it is still not even a constant. I do agree it can sometimes be helpful to warn about compound boolean expressions that are constant; we already have those for most statements.
Otherwise, we are introducing counterproductive diagnostics that are literally guesses for the compiler, which is of course discouraged.

I made a big mistake in the first post, please recheck. Sorry

It wouldn't even have to be that complicated; some C++ compilers for example warn when there's the same expression on both sides of some operators. Candidates for that would be || or && as well as ==, plus probably some others...?

Boolean expressions are often intentionally written in an expanded form for readability purposes. Although occasionally this might be exactly what you want, imagine how annoying these warnings can become in general. However, if we were to use notes instead, the idea becomes more reasonable. There's one problem though: standalone notes aren't shown inline, at least in Xcode, so there's no point in attaching fixits to them.

I am also sceptic towards making this part of the compiler. Architecturally, it would be much more suitable for it to be a native and optional build phase.