Skip to content

Instantly share code, notes, and snippets.

@jdh30

jdh30/Init.fs

Last active Feb 28, 2020
Embed
What would you like to do?
Avoiding the undebuggable type initialization exception in F#
let mutable globalException : System.Exception = null // Compiler generated
let myGlobal =
if isNull globalException then // Compiler generated
try // Compiler generated
System.IO.File.ReadAllText "DoesNotExist.txt"
with e -> // Compiler generated
globalException <- e // Compiler generated
Unchecked.defaultof<_> // Compiler generated
else Unchecked.defaultof<_> // Compiler generated
let main args =
if not(isNull globalException) then // Compiler generated
raise globalException // Compiler generated
printfn "%s" myGlobal
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.