Docs menu

E166: A value is compared with itself

What compiler warning E166 means, and how to fix it.

A warning, on by default.

Comparing a variable with itself gives an answer that never changes:

Example
immut a: int = 3;if a == a {              // WARNING: always true    printline("same");}

a == a, a <= a and a >= a are always true; a != a, a < a and a > a are always false. (For a double, x != x is the classic NaN check, and Turf’s warning says “unless the value can be NaN” there.) It is nearly always a typo for a comparison with a different variable:

Example
immut a: int = 3;immut b: int = 3;if a == b {    printline("same");}

If the self-comparison really is intentional, such as an x != x NaN test, allowing the warning is the right tool.

This is a warning, not an error – compilation still succeeds. To silence it for a whole build, set its lint level to allow: turf build --allow E166 (or [lints] E166 = "allow" in turf.toml).

Run turf --explain E166 in a terminal to read this again.

Last updated: Oct 15, 2026Edit this page on GitHub

Esc

Type to search.