Strict Term Equivalence

View Source

Term [non-]equivalence (=:=, =/=) should be used instead of term [non-]equality (==, /=).

Avoid

Expr1 == Expr2 andalso Expr3 /= Expr4

Prefer

Expr1 =:= Expr2 andalso Expr3 =/= Expr4

Rationale

== and /= perform numeric coercion, that may hide type errors or logic bugs.

=:= and =/= are safer (and more defensive) for logic, guards, and type-sensitive operations.

Using strict term equivalence also eliminates the need to have implicit assumptions about data types and their representation, while encouraging explicit handling of mismatched types.

Options

  • None.

Example configuration

{elvis_style, strict_term_equivalence, #{}}