From 6df16975cacd4e9d1fe1664903e3f0d5c4a6b739 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Fri, 3 Mar 2017 14:15:11 +0100 Subject: [PATCH] fix bug in `CCOpt.filter` (close #100) --- src/core/CCOpt.ml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/CCOpt.ml b/src/core/CCOpt.ml index 85361b04..355473c2 100644 --- a/src/core/CCOpt.ml +++ b/src/core/CCOpt.ml @@ -67,7 +67,13 @@ let map2 f o1 o2 = match o1, o2 with let filter p = function | Some x as o when p x -> o - | o -> o + | _ -> None + +(*$= + None (filter ((=) 0) (Some 1)) + (Some 0) (filter ((=) 0) (Some 0)) + None (filter (fun _ -> true) None) +*) let if_ p x = if p x then Some x else None