caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Mark Shinwell" <mshinwell@janestcapital.com>
To: caml-list@inria.fr
Subject: Type checker (ex-)bug
Date: Wed, 18 Jun 2008 14:21:40 -0400	[thread overview]
Message-ID: <20080618182140.GK30596@janestcapital.com> (raw)

The following program:

    type 'a s = 'a
    type 'a t = unit
    
    let g (_ : 'a s -> unit) (_ : 'a t) = ()
    let f t = g (fun x -> x; ()) t

fails to typecheck using ocamlc 3.10.0 but succeeds (as would surely be
expected) under 3.10.1 and 3.10.2.  The 3.10.0 compiler complains:

    File "foo.ml", line 5, characters 6-30:
    The type of this expression, '_a t -> unit,
    contains type variables that cannot be generalized

The fix for this bug doesn't appear to be explicitly noted in the Changes
file, but it was fixed by this patch, which was introduced between 3.10.0
and 3.10.1:

@@ -585,8 +585,11 @@
 let add_delayed_check f = delayed_checks := f :: !delayed_checks
 let force_delayed_checks () =
+  (* checks may change type levels *)
+  let snap = Btype.snapshot () in
   List.iter (fun f -> f ()) (List.rev !delayed_checks);
-  reset_delayed_checks ()
+  reset_delayed_checks ();
+  Btype.backtrack snap

Could someone comment whether this patch is indeed the correct fix for
this problem (I assume it was written to fix something else)?  Or is
there perhaps still something wrong that is being masked by this patch?

Thanks in advance.
Mark


             reply	other threads:[~2008-06-18 18:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-18 18:21 Mark Shinwell [this message]
2008-06-19  2:16 ` [Caml-list] " Jacques Garrigue

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=20080618182140.GK30596@janestcapital.com \
    --to=mshinwell@janestcapital.com \
    --cc=caml-list@inria.fr \
    /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).