F# Interactive bug?
Posted
by
John Reynolds
on Stack Overflow
See other posts from Stack Overflow
or by John Reynolds
Published on 2010-12-30T13:44:12Z
Indexed on
2010/12/30
13:54 UTC
Read the original article
Hit count: 285
F#
|f#-interactive
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 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 ()
then there is no error. F# bug or my mistake?
© Stack Overflow or respective owner