A condition requires one value to meet two comparisons that no value meets together
What it finds
if n > 10 && n < 5 or if kind == "a" && kind == "b": no value is in both ranges, or equal to two different constants, so the condition is always false and its branch never runs. Usually || was meant, or a bound is wrong.
Reported are chains of && in which the same expression, without calls or receives, is compared with ==, <, <=, > or >= to integer literals, or with == to constant strings, in ways no value satisfies together. Bounds are compared as real numbers, so x > 1 && x < 2, which a float can satisfy, is left alone.
From the rule's source, impossible_conjunction.rs.
package p func f(n int, x float64, s string) bool { if n > 10 && n < 5 {tx0 reports: no value of n meets both comparisons return true } if s == "a" && s == "b" {tx0 reports: no value of s meets both comparisons return true } if n >= 3 && 3 >= n { return true } if 7 < n && n <= 7 {tx0 reports: no value of n meets both comparisons return true } return x > 1 && x < 2 || n > 0 && n < 10} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/go:impossible-conjunction" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/go:impossible-conjunction] reason="..."tx0 explain tx0/go:impossible-conjunction shows the same in the terminal. Found a false positive? Report it.