warning FS0025: Incomplete pattern matches on this expression

在看F#的模式匹配的时候,遇到一个问题:

let f x =
    match x with
    | _ when x < 0 -> -1
    | _ when x = 0 -> 0
    | _ when x > 0 -> 1;;

这段代码会报一个警告:warning FS0025: Incomplete pattern matches on this expression.

在《Programming F#》里,提到,如果模式匹配的时候,如果没有完全覆盖所有情况,会报这个异常,可是,上面的例子是完全覆盖了,为什么还会有这个警告呢?

原文地址:https://www.cnblogs.com/FMax/p/1745749.html