Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bogus "Duplicate definition of value" error from the F# compiler

Tags:

f#

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?

like image 492
J D Avatar asked May 14 '12 09:05

J D


1 Answers

This happens when you also define a get_foo function:

let get_foo() = !foo

because the definition of foo creates a property that implements its own get_foo method 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#.

like image 166
J D Avatar answered Sep 28 '22 09:09

J D