Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
compiler wrongly reports "The types for field x are not equal." #6342
Original bug ID: 6342
The compiler gives some wrong information for 2 type declarations that don't match.
Steps to reproduce
$ cat mt.ml
The last part "The types for field x are not equal." is wrong and sounds random, since 1. the error is elsewhere and 2. the types for field x are actually well equal...
Tried with 3.12.1, 4.00.1 and 4.01.0.
Comment author: @lefessan
For me, the two types are indeed not equal: 'a has a constraint internally, whereas the interface has no constraint. With the interface, you can create a value of type "int v", whereas the code in the implementation expects a "[> `X] v", i.e. would fail on an "int v".
Comment author: @damiendoligez
The problem is in
When the type parameters are incompatible, it will always give the error on the first field, even if this field doesn't involve the incompatible parameters.
For a more striking example, you can remove field
I've no idea how to fix this.