ocaml/ocaml — pull request #87 by yallop (2014-08-04 15:30:23+00:00)
Title: Fix docstrings saying when Invalid_argument is raised for list functions.

I've been migrating some list-processing code to use [Core_kernel][core_kernel] instead of the [standard library][stdlib] and noticed that the documentation strings for the two libraries have somehow become interchanged. The standard library documentation for `List.exists2` [says][stdlib-exists2]:

> Same as `List.exists`, but for a two-argument predicate. Raise `Invalid_argument` if the two lists have different lengths.

In fact, `List.exists2` does not always raise `Invalid_argument` if the two lists have different lengths:

```ocaml
# List.exists2 (>) [1; 2] [3; 1; 0];;
- : bool = true
```

On the other hand, the documentation for `Core.Std.List.exists2_exn` [says][core-exists2]:

> Same as `List.exists`, but for a two-argument predicate. Raise `Invalid_argument` if the end of one list is reached before the end of the other.

In fact, `Core.Std.List.exists2_exn` can fail even the predicate is satisfied (which should mean that the ends of the lists are not reached):

```ocaml
# Core_kernel.Std.List.exists2_exn ~f:(>) [1; 2] [3; 1; 0];;
Exception: Invalid_argument "length mismatch in exists2_exn: 2 <> 3 ".
```

This changeset rectifies the situation for various functions in the standard library.

[core_kernel]: https://github.com/janestreet/core_kernel
[stdlib]: https://github.com/ocaml/ocaml/tree/trunk/stdlib
[stdlib-exists2]: https://github.com/ocaml/ocaml/blob/68fe1eb/stdlib/list.mli#L160-L163
[core-exists2]: https://github.com/janestreet/core_kernel/blob/c1dcec751/lib/core_list.mli#L73-L76