FSharpTypeFunc.Specialize导致TypeLoadException

FSharpTypeFunc.Specialize导致TypeLoadException,exception,f#,Exception,F#,我得到以下运行时异常: System.TypeLoadException未处理 类型[…]上的Message=方法“Specialize”试图隐式重写具有较弱类型参数约束的方法 这一内部功能似乎是问题所在: let getKey (r: IDictionary<_,_>) = match r.TryGetValue(keyCol.Name) with | true, k when not (isNull k) -> Some k | _ -> None 这

我得到以下运行时异常:

System.TypeLoadException未处理
类型[…]上的Message=方法“Specialize”试图隐式重写具有较弱类型参数约束的方法

这一内部功能似乎是问题所在:

let getKey (r: IDictionary<_,_>) = 
  match r.TryGetValue(keyCol.Name) with
  | true, k when not (isNull k) -> Some k
  | _ -> None
这是Visual Studio 2008中的一个控制台应用程序,目标是.NET 4.0。奇怪的是,代码在FSI中工作

下面是程序集的PEVerify输出:

[令牌0x02000004]类型加载失败。
[IL]:错误:[D:\TEST\bin\Debug\TEST.exe:测试+test@10[a] ::GenerateNext][mdToken=0x6000012][offset 0x00000031]无法解析令牌。
验证D:\TEST\bin\Debug\TEST.exe时出现2个错误


将其发送给fsbugs,并收到已修复的回复。

听起来可能是一个bug,但如果您发布完整的重新编译将对您有所帮助-您列出的代码对我来说编译得很好(免费标识符有一些任意定义)。很好,看起来确实像个bug!它会随着
让内联
消失吗?@kvb:I添加了一个复制。似乎将其包装在
seq{}
块中会导致问题。@toyvo:是的,
inline
没有任何区别。我继续将其发送给fsbugs。
open System.Collections.Generic

let isNull = function null -> true | _ -> false
type KeyCol = { Name : string }

let test() =
  seq {
    let keyCol = { Name = "" }
    let getKey (r: IDictionary<_,_>) = 
      match r.TryGetValue(keyCol.Name) with
      | true, k when not (isNull k) -> Some k
      | _ -> None
    getKey (dict ["", box 1])
  }

test() |> Seq.length |> printfn "%d"