caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] typechecking in 4.05+beta2
@ 2017-02-22 18:54 Virgile Prevosto
  2017-02-24  8:47 ` Virgile Prevosto
  0 siblings, 1 reply; 4+ messages in thread
From: Virgile Prevosto @ 2017-02-22 18:54 UTC (permalink / raw)
  To: OCAML

Dear list,

while playing with the new beta, I stumbled upon the following issue.
The program below is now rejected by the compiler, while this was not
the case with 4.04.

--- test.mli:
module M(E: sig type t end): sig
type t
val u: t -> t -> t
end

--- test.ml:
module M(E: sig type t end) = struct
type t = (E.t, unit) Hashtbl.t
let u = Hashtbl.fold (fun x () h -> Hashtbl.add h x (); h)
end

---
ocamlc test.mli
ocamlc test.ml
File "test.ml", line 1:
Error: The implementation test.ml does not match the interface test.cmi:
       ...
       At position module M(E) : <here>
       Modules do not match:
         sig
           type t = (E.t, unit) Hashtbl.t
           val u :
             ('_a, unit) Hashtbl.t ->
             ('_a, unit) Hashtbl.t -> ('_a, unit) Hashtbl.t
         end
       is not included in
         sig type t val u : t -> t -> t end
       At position module M(E) : <here>
       Values do not match:
         val u :
           ('_a, unit) Hashtbl.t ->
           ('_a, unit) Hashtbl.t -> ('_a, unit) Hashtbl.t
       is not included in
         val u : t -> t -> t
       File "test.ml", line 3, characters 4-5: Actual declaration

It is quite easy to fix, but I was wondering whether this restriction
in type unification when checking the conformance of .ml and .mli was
intended, and if yes, what is the reason behind it?
Note that this is of course a reduction of the initial code, and all
ingredients seems to be needed.

Best regards,
-- 
E tutto per oggi, a la prossima volta
Virgile

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-24 18:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-22 18:54 [Caml-list] typechecking in 4.05+beta2 Virgile Prevosto
2017-02-24  8:47 ` Virgile Prevosto
2017-02-24 16:14   ` Gabriel Scherer
2017-02-24 18:19     ` Virgile Prevosto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).