ocaml.lang.correctness.physical-vs-structural.physical-not-equal

profile photo of returntocorpreturntocorp
Author
169
Download Count*

You probably want the structural inequality operator <>

Run Locally

Run in CI

Defintion

rules:
  - id: physical-not-equal
    pattern: $X != $Y
    message: You probably want the structural inequality operator <>
    languages:
      - ocaml
    severity: WARNING
    metadata:
      category: correctness
      technology:
        - ocaml
      references:
        - https://v2.ocaml.org/api/Stdlib.html#1_Comparisons
      license: Commons Clause License Condition v1.0[LGPL-2.1-only]

Examples

physical-vs-structural.ml

let test xs ys =
  (* ruleid:physical-not-equal *)
  if xs != ys
  then 1
  else 2

let test2 xs ys =
  (* ruleid:physical-equal *)
  if xs == ys
  then 1
  else 2