给出以下代码:
type MyDU = | B of bool | I of int | S of string type Ops () = static member myFn<'T> x = let v = match x with | B b -> box b | I i -> box i | S s -> box s match v with | :? 'T as y -> Some y | _ -> None
......以下产品error FS0717: Unexpected type arguments
:
I 7 |> Ops.myFn
Ops.myFn
但是,这很好用:
Ops.myFn
另外,如果我myFn
在模块中定义,我没有错误:
let myFn<'T> x = let v = match x with | B b -> box b | I i -> box i | S s -> box s match v with | :? 'T as y -> Some y | _ -> None I 7 |> myFn// Works fine
说明?