Error when initializing a mutable record with the `int list' type

Hello everybody,

Where is an error here?
Sorry for asking maybe an extremely simple question, but the err. message is not clear for me.

type v = {mutable c: int list; mutable t: int};;
let b = {c=[1]; t=1};;

the error message is

Error: This expression has type 'a list/9
       but an expression was expected of type int list/1032

When you see a error messages like t/1 is not compatible with type t/2 this means that there are multiple definitions of the type t visible in the current scope. In your case, there is two visible definitions of the type constructor list: the list literal [1] has for type the predefined list type 'a list/9 whereas your record definition refers to an user (or library) defined list constructor list/1032 . Without more context, it is hard to say from where this second list type constructor comes from.

(This kind of error can happen quite often within the toplevel when refining the same type in multiple phrases)

1 Like