Last active
February 28, 2020 01:05
-
-
Save jdh30/034c5de27a1ef386e7534ad9cf933122 to your computer and use it in GitHub Desktop.
Avoiding the undebuggable type initialization exception in F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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