Consider the following code example:
function
| [] -> "bla"
| ds -> let x::l = List.rev ds in "woot";;
When compiling / interpreting the above piece of code the following warning occur:
line 3, characters 14-18:
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
[]
I wonder why this warning appear. It is clear that [] is not a valid option due to the top level pattern-matching. I expect the compiler / interpreter of OCaml to be able to easily deduce the exhaustiveness of the above code by passing information from the top-level matching to the nested matching. Why isn't that the case? Am I missing something?