Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006342OCamlOCaml typingpublic2014-03-07 07:292014-09-15 09:53
Reporterpw374 
Assigned Tolefessan 
PrioritynormalSeverityminorReproducibilityalways
StatusfeedbackResolutionopen 
PlatformOSOS Version
Product Version4.01.0 
Target Versionafter-4.02.1Fixed in Version 
Summary0006342: compiler wrongly reports "The types for field x are not equal."
DescriptionThe compiler gives some *wrong* information for 2 type declarations that don't match.
Steps To Reproduce$ cat mt.ml
module M = struct
  type 'a v = {
    x : int;
    v : 'a;
  } constraint 'a = [> `X ]
end
$ cat mt.mli
module M : sig type 'a v = { x : int; v : 'a; } end
$ ocamlc -c mt.mli
$ ocamlc -c mt.ml
File "mt.ml", line 1:
Error: The implementation mt.ml does not match the interface mt.cmi:
       In module M:
       Modules do not match:
         sig
           type 'a v = 'a M.v = { x : int; v : 'a; } constraint 'a = [> `X ]
         end
       is not included in
         sig type 'a v = { x : int; v : 'a; } end
       In module M:
       Type declarations do not match:
         type 'a v = 'a M.v = { x : int; v : 'a; } constraint 'a = [> `X ]
       is not included in
         type 'a v = { x : int; v : 'a; }
       File "mt.ml", line 2, characters 6-68: Actual declaration
       The types for field x are not equal.
$


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...
Additional InformationTried with 3.12.1, 4.00.1 and 4.01.0.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0011019)
lefessan (developer)
2014-03-07 09:50

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".
(0011020)
dbuenzli (reporter)
2014-03-07 10:03

Fabrice, the *field name* mentioned is wrong in the error message, it should be "the type for field v are not equal".
(0011021)
lefessan (developer)
2014-03-07 10:14

Indeed !

- Issue History
Date Modified Username Field Change
2014-03-07 07:29 pw374 New Issue
2014-03-07 09:50 lefessan Note Added: 0011019
2014-03-07 09:51 lefessan Assigned To => lefessan
2014-03-07 09:51 lefessan Status new => feedback
2014-03-07 10:03 dbuenzli Note Added: 0011020
2014-03-07 10:14 lefessan Note Added: 0011021
2014-07-16 18:24 doligez Target Version => 4.02.1+dev
2014-09-04 00:25 doligez Target Version 4.02.1+dev => undecided
2014-09-15 09:53 doligez Target Version undecided => after-4.02.1


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker