caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Typing issue in explicit module
@ 2017-08-29 19:13 Paul A. Steckler
  2017-08-30 22:20 ` Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: Paul A. Steckler @ 2017-08-29 19:13 UTC (permalink / raw)
  To: caml-list

Here's some code that compiles successfully with 4.05.0 ocamlc. The .ml file is:

.ml file:
--
    type t
    let id x = x
    let idid = id id
--
.mli file:
--
  type t
  val id: 'a -> 'a
  val idid : t -> t
--

If I wrap the code in an explicit module, I get a type error:

.ml file:
--
module Foo =
  struct
  <code as before>
  end
--
.mli file:
--
module Foo :
 sig
   <code as before>
 end
--

With this change made, ocamlc complains:

--
Error: The implementation Foo.ml does not match the interface Foo.cmi:
       In module Foo:
       Modules do not match:
         sig type t = Foo.t val id : 'a -> 'a val idid : '_a -> '_a end
       is not included in
         sig type t val id : 'a -> 'a val idid : t -> t end
       In module Foo:
       Values do not match:
         val idid : '_a -> '_a
       is not included in
         val idid : t -> t
--

Adding a type annotation t -> t to the definition of "idid" gets rid
of the error.

With OCaml 4.04.0, no error occurs, and the type annotation is
unnecessary. Is this change expected?

The code I've shown is a simplified version of OCaml code extracted
from a Coq script, reported as a bug in Coq:
https://coq.inria.fr/bugs/show_bug.cgi?id=5705.

-- Paul

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

end of thread, other threads:[~2017-08-30 22:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-29 19:13 [Caml-list] Typing issue in explicit module Paul A. Steckler
2017-08-30 22:20 ` Jacques Garrigue

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).