The F# compiler sometimes rejects my code with a compile-time error of the form Duplicate definition of value foo pointing at a definition like this:
let foo = ref 0
even though this is not a duplicate definition because there are no other definitions of foo in the whole file. Why does this happen?
This happens when you also define a
get_foofunction:because the definition of
foocreates a property that implements its ownget_foomethod so there is a clash. The F# compiler is confused by this and generates the bogus “duplicate definition error”.This bug has been reported to Microsoft and they are working on a fix but it won’t make it into the next (VS11) release of F#.