不能声明受歧视工会的成员
Cannot declare a member of a Discriminated Union
以下代码给出了关于“不够通用”的编译错误。
怎么了?
type SameLenVectors<'T when 'T: (static member (+): 'T * 'T -> 'T) and 'T: (static member (*): 'T * 'T -> 'T)> =
private SameLenVectors of 'T list list
member this.Item = 1
'T
是一个 statically resolved type parameter (SRTP),因此它必须在调用站点内联:
member inline this.Item = 1
这有点令人困惑,因为您将类型参数声明为 'T
而不是 ^T
,但它仍然是一个 SRTP(由编译器错误证明)。
以下代码给出了关于“不够通用”的编译错误。 怎么了?
type SameLenVectors<'T when 'T: (static member (+): 'T * 'T -> 'T) and 'T: (static member (*): 'T * 'T -> 'T)> =
private SameLenVectors of 'T list list
member this.Item = 1
'T
是一个 statically resolved type parameter (SRTP),因此它必须在调用站点内联:
member inline this.Item = 1
这有点令人困惑,因为您将类型参数声明为 'T
而不是 ^T
,但它仍然是一个 SRTP(由编译器错误证明)。