Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 598 Bytes

5009.md

File metadata and controls

29 lines (21 loc) · 598 Bytes

5009

A real literal was used as a pattern.

fun f (x : real) : int =
  case x of
    1.2 => 3
(** ^^^ real literal used as a pattern *)
  | _ => 4

To fix

Consider checking that the given real is within some epsilon value of the desired real.

val eps = 0.01

fun f (x : real) : int =
  if Real.abs (x - 1.2) <= eps then
    3
  else
    4

Usage of Real.== to check for equality between reals is discouraged, due to limitations around representing floating-point (aka, real) numbers on most architectures.