I wrote some code by accident today and was surprised when Eclipse did not yell at me, for once. The code had a double use of the structural equality operator (==
The == operator is left-associative, so a == b == c is interpreted as (a == b) == c. So a == b returns a bool, which is then compared to c.
This is a side effect of the parser that is rarely useful in practice. As you've observed, it looks like it does one thing but does something very different (so even if it does what you want, it's not recommended). Some languages actually make the == operator non-associative, so a == b == c is a syntax error.