From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 9316C7FBFF for ; Fri, 23 Jan 2015 15:43:37 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.09,454,1418079600"; d="scan'208";a="97481006" Received: from adijon-652-1-166-140.w90-56.abo.wanadoo.fr (HELO alcazar2) ([90.56.101.140]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 23 Jan 2015 15:43:24 +0100 Date: Fri, 23 Jan 2015 15:43:23 +0100 From: Maxence Guesdon To: caml-list@inria.fr Message-ID: <20150123154323.1fc8e7d8@alcazar2> Organization: INRIA X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [Caml-list] Strange type inference error Hello, I encountered a strange typing problem and reduced it to the following code example: ====[t.ml]==== let mk_env () = None let list_of_string (s: string) = [s] let apply : 'a -> 'a option -> string list -> 'a * string list = fun acc env l -> (acc, ["hello"]) let f = let tmpl = ["coucou"] in fun ?(env=mk_env()) -> fun ~x -> fun () -> apply () env tmpl let g = let tmpl = list_of_string "coucou" in fun ?(env=mk_env()) -> fun ~x -> fun () -> apply () env tmpl ==== Note that f and g only differ on the way tmpl is defined. When I compile this file with ocaml 4.02.1, I get the following error: File "t.ml", line 14, characters 3-119: Error: The type of this expression, ?env:unit option -> x:'_a -> unit -> unit * string list, contains type variables that cannot be generalized Am I missing something or should I file a bug report ? Regards, Maxence