Skip to content

Instantly share code, notes, and snippets.

@dtchepak
Created February 23, 2014 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtchepak/9169907 to your computer and use it in GitHub Desktop.
Save dtchepak/9169907 to your computer and use it in GitHub Desktop.
Private constructor in sum type crashes `sprintf "%A"`?
module MyModule
open Xunit
open FsUnit.Xunit
type Sample = Sample of int
with override x.ToString() = sprintf "%A" x
[<Fact>]
let ``sample to string`` ()=
let actual = Sample 1
actual.ToString() // all good
type Sample2 = private Sample2 of int
with override x.ToString() = sprintf "%A" x
[<Fact>]
let ``sample2 to string`` ()=
let actual = Sample2 1
actual.ToString() // Stack overflow?!??!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment