From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id E2D89BC37 for ; Tue, 27 Oct 2009 11:28:26 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmkNANNn5krRVd7Li2dsb2JhbACCITKPJokEPwEBAQoLCgcRBa0MhkWIaAEDAwWEOgSJRg X-IronPort-AV: E=Sophos;i="4.44,632,1249250400"; d="scan'208";a="35673231" Received: from mail-pz0-f203.google.com ([209.85.222.203]) by mail2-smtp-roc.national.inria.fr with ESMTP; 27 Oct 2009 11:28:26 +0100 Received: by pzk41 with SMTP id 41so913pzk.0 for ; Tue, 27 Oct 2009 03:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=4QOqfhBfGKnwOWzBE6yQc77Efxc9j5HTcNmjv8kMq7M=; b=CELm2I0JsyR2Ii2ze0CXC849T4QZpZ0isH0xH++GJsQqNAM4SV1QnSnhwEvZpjLMRv JfssPR9rO2ogv1uJLB1Xzh3WGogl5xVYmslEgipY+fD62yuyyLfJVrSTq5PRfjWoZOfC hJ//9GyAqAQVz/1v/QW7o8YecU3felwnphrzs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=G3Y/IlFIq3zfI4cw7iuupPrUoK3rtTavT5cOHTUzgOgrarmnMZaYDolE9HAQ82OPz9 Dzje4kAyg4iy3ACon1Da1JYWfTQxexxBNf4mtTaH6WflGZbL+ATnuzJRp7bZTui83JBC XRYjsAHWkMeta7fO0+7vbQTM5a/o9MKATIVnY= MIME-Version: 1.0 Sender: marc.defalco@gmail.com Received: by 10.141.23.5 with SMTP id a5mr181817rvj.108.1256639305254; Tue, 27 Oct 2009 03:28:25 -0700 (PDT) Date: Tue, 27 Oct 2009 11:28:25 +0100 X-Google-Sender-Auth: 80b9eff46633b7dc Message-ID: Subject: A strange typing error with polymorphic variants From: Marc de Falco To: caml-list@inria.fr Content-Type: multipart/alternative; boundary=000e0cd1b7b86688df0476e82345 X-Spam: no; 0.00; variants:01 bug:01 mutable:01 sqrt:01 val:01 ocaml:01 val:01 bug:01 mutable:01 sqrt:01 ocaml:01 2.0:98 2.0:98 polymorphic:01 typing:01 --000e0cd1b7b86688df0476e82345 Content-Type: text/plain; charset=ISO-8859-1 Hi, I've come across a very strange error, and I'm not sure if it is a bug or a feature. The following code : type 'a p = R of 'a t | E of float and 'a t = { mutable p : 'a p; c : 'a } let f = let x = sqrt(2.0) in fun () -> { c = `A; p = E 0.0 } generates the error : The type of this expression, unit -> _[> `A ] t, contains type variables that cannot be generalized but if I change the x definition to "let x = 2.0 in" then it works. Another solution is to add a dummy parameter "let f ?(dummy=())" this works too. When I say that it works, I mean that the resulting type of f is val f : unit -> [> `A ] t I've seen that in the dev version of ocaml this error has been removed but the type of f is still "val f : unit -> _[> `A] t" which is not the thing that I want. Is that an expected behavior ? Marc --000e0cd1b7b86688df0476e82345 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi, I've come across a very strange error, and I'm not sure if it i= s
a bug or a feature.

The following code :
type 'a p =3D R= of 'a t | E of float
=A0=A0=A0 and 'a t =3D { mutable p : '= a p; c : 'a }
let f =3D
=A0=A0=A0 let x =3D sqrt(2.0) in
=A0=A0=A0 fun () -> { = c =3D `A; p =3D E 0.0 }

generates the error :
=A0 The type of th= is expression, unit -> _[> `A ] t,
=A0 contains type variables tha= t cannot be generalized

but if I change the x definition to "let x =3D 2.0 in" then i= t works.

Another solution is to add a dummy parameter "let f ?= (dummy=3D())" this works too.
When I say that it works, I mean that= the resulting type of f is
=A0val f : unit -> [> `A ] t
I've seen that in the dev version= of ocaml this error has been removed but
the type of f is still "val f : unit -> _[> `A] t" which is= not the thing that I want.

Is that an expected behavior ?

Ma= rc
--000e0cd1b7b86688df0476e82345--