开发者

F# Interactive bug?

I've tried the following code in 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

If I highlight all code and send it to F# Interactive (Alt+Enter), then rsaTest1 works, but rsaTest2 gives an error message,

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

However, if I change rsaTest2 from a value into a function and call it,

let r开发者_如何学编程saTest2 () =
    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 ()

then there is no error. F# bug or my mistake?


This is most likely a bug - if you compile the posted snippet with fsc and run it, you get this for x64:

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

and this for x86:

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

You should report it via Microsoft Connect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜