caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: "Paul A. Steckler" <steck@stecksoft.com>
Cc: Mailing List OCaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Typing issue in explicit module
Date: Thu, 31 Aug 2017 07:20:32 +0900	[thread overview]
Message-ID: <E06820A8-3503-4017-86D5-AA8D1452F3F9@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <CAMSKV5ceyX3nb1BoraS3M5YOV99J5GtfVPERLwtnKKN-+Aa2mw@mail.gmail.com>

This is a known issue to fixing a long standing soundness problem in ocaml 4.04
(I believe you are wrong in saying that it did work in 4.04, it should rather be 4.03 or 4.02).

https://caml.inria.fr/mantis/view.php?id=7313

Basically, non-generalizable type variables in inner modules should be instantiated before
leaving the module, if you want to instantiate them with local types.
This is needed to ensure correct scoping in complex situations.
Your solution is the correct one.

Jacques Garrigue

2017/08/30 4:13, Paul A. Steckler <steck@stecksoft.com>:
> 
> 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
> 
> -- 
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs


      reply	other threads:[~2017-08-30 22:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-29 19:13 Paul A. Steckler
2017-08-30 22:20 ` Jacques Garrigue [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E06820A8-3503-4017-86D5-AA8D1452F3F9@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=steck@stecksoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).