[英]F# Interactive bug?
我在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
如果我突出显示所有代码并将其发送到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
但是,如果我将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 ()
那就没有错误。 F#错误还是我的错误?
这很可能是一个错误-如果您使用fsc编译发布的代码段并运行它,则可以在x64上获得此代码:
Unhandled Exception: System.InvalidProgramException: Common Language Runtime detected an invalid program.
at <StartupCode$test>.$Test.main@()
而对于x86:
Unhandled Exception: System.InvalidProgramException: JIT Compiler encountered an internal limitation.
at <StartupCode$test>.$Test.main@()
您应该通过Microsoft Connect报告它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.