List.map3 (fun () () () -> ()) [();()] [()] [()]
// System.ArgumentException: The lists had different lengths.
// list1.Length = 1, list2.Length = 0, list3.Length = 0
This is misleading because the lists in user code have lengths 2,1,1 not 1,0,0.
src/fsharp/FSharp.Core/local.fs
let map3 mapping xs1 xs2 xs3 =
match xs1, xs2, xs3 with
| [], [], [] -> []
| h1 :: t1, h2 :: t2, h3 :: t3 ->
...
map3ToFreshConsTail cons f t1 t2 t3
cons
| xs1, xs2, xs3 -> ...
map3ToFreshConsTail operates on t1,t2,t3, recursively pops heads off, and fails if at least one but not all of the input lists are empty. It then reports the lengths of the current lists, not the lengths of the original lists.
A fix:
try
map3ToFreshConsTail cons f t1 t2 t3
cons
with _ ->
invalidArg3ListsDifferent "list1" "list2" "list3" xs1.Length xs2.Length xs3.Length
This is misleading because the lists in user code have lengths 2,1,1 not 1,0,0.
src/fsharp/FSharp.Core/local.fs
map3ToFreshConsTailoperates on t1,t2,t3, recursively pops heads off, and fails if at least one but not all of the input lists are empty. It then reports the lengths of the current lists, not the lengths of the original lists.A fix: