F#互动错误?

Joh*_*lds 0 f# f#-interactive

我在VS2010中尝试了以下代码:

open System.Security.Cryptography

let rsaTest1 =
    let ecKey = [|0uy..143uy|] // junk data for testing

    let ecKeyMod = ecKey.[8..8+128-1]   
    let ecKeyExp = ecKey.[136..136+8-1]
    let rsa = RSAParameters(Modulus = ecKeyMod, Exponent = ecKeyExp)

    rsa


let rsaTest2 =
    let ecKey = [|0uy..143uy|] // junk data for testing

    let rsa = RSAParameters(Modulus = ecKey.[8..8+128-1], Exponent = ecKey.[136..136+8-1])

    rsa
Run Code Online (Sandbox Code Playgroud)

如果我突出显示所有代码并将其发送到F#Interactive(Alt + Enter),则rsaTest1可以工作,但rsaTest2会给出错误消息,

System.NullReferenceException: Object reference not set to an instance of an object.
   at <StartupCode$FSI_0004>.$FSI_0004.main@() in P:\proj\Tachograph\Project\CompuTachTest\CompuTachTest\rsaTest.fsx:line 16
Run Code Online (Sandbox Code Playgroud)

但是,如果我将rsaTest2从值更改为函数并调用它,

let rsaTest2 () =
    let ecKey = [|0uy..143uy|] // junk data for testing
    let rsa = RSAParameters(Modulus = ecKey.[8..8+128-1], Exponent = ecKey.[136..136+8-1])
    rsa

let x = rsaTest2 ()
Run Code Online (Sandbox Code Playgroud)

那就没有错误.F#bug还是我的错误?

zeu*_*xcg 5

这很可能是一个错误 - 如果您使用fsc编译已发布的代码段并运行它,您可以获得x64:

Unhandled Exception: System.InvalidProgramException: Common Language Runtime detected an invalid program.
at <StartupCode$test>.$Test.main@()
Run Code Online (Sandbox Code Playgroud)

这对于x86:

Unhandled Exception: System.InvalidProgramException: JIT Compiler encountered an internal limitation.
at <StartupCode$test>.$Test.main@()
Run Code Online (Sandbox Code Playgroud)

您应该通过Microsoft Connect报告它.