Two labels or constructors of the same name are defined in two mutually recursive types

If you write a code like this:

type rec a = B(b) | C(c)
and b = {str: string, a: a}
and c = {str: string, num: int, a: a}

You’ll get a warning “the label str is defined in both types b and c.”, there’s a bit more information in Warning Numbers | ReScript Language Manual :

Two labels or constructors of the same name are defined in two mutually recursive types.

But I still don’t understand why this is bad and produces a warning.

I know having the same field names can be bad in general as the compiler determines types based on field names and can get confused. But why this produces a warning specifically when the types are mutually recursive?

1 Like

Btw, if you don’t get an answer here, try cross-posting to the OCaml discuss.ocaml.org forum, they know a lot. :slight_smile:

There are also OCaml and ReasonML Discord channels.

1 Like

Got an answer there What is warning 30 for? - #4 by octachron - Learning - OCaml . Thanks for suggesting the forum!

3 Likes