From 39e0ad2395d0c9772d5d4f37322463d52889965a Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 28 Jul 2020 16:27:02 -0400 Subject: [PATCH] fix(pool): missing emptiness check in Fut.map_l also add regression test --- src/threads/CCPool.ml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/threads/CCPool.ml b/src/threads/CCPool.ml index 2395d58e..b1726f2d 100644 --- a/src/threads/CCPool.ml +++ b/src/threads/CCPool.ml @@ -530,9 +530,17 @@ module Make(P : PARAM) = struct (* reverse twice *) let map_l f l = - let l = List.rev_map f l in - sequence_ (L_ l) - (fun () -> List.rev_map get_nolock_ l) + match l with + | [] -> return [] + | _ -> + let l = List.rev_map f l in + sequence_ (L_ l) + (fun () -> List.rev_map get_nolock_ l) + + (*$= + [2;3] (Fut.get @@ Fut.map_l (fun x -> Fut.return (x+1)) [1;2]) + [] (Fut.get @@ Fut.map_l (fun x -> Fut.return (x+1)) []) + *) (*$R let l = CCList.(1 -- 50) in