From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 79C35BBAF for ; Tue, 24 Jun 2008 20:17:42 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoQBAL/WYEiACH+SiGdsb2JhbACScQEBAQ8goHw X-IronPort-AV: E=Sophos;i="4.27,697,1204498800"; d="scan'208";a="26665612" Received: from server-nat-3.cs.umd.edu (HELO bacon.cs.umd.edu) ([128.8.127.146]) by mail4-smtp-sop.national.inria.fr with ESMTP; 24 Jun 2008 20:17:41 +0200 Received: from 129-2-134-199.wireless.umd.edu (129-2-134-199.wireless.umd.edu [129.2.134.199]) (authenticated bits=0) by bacon.cs.umd.edu (8.13.1/8.14.1) with ESMTP id m5OIHcBl024407 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Tue, 24 Jun 2008 14:17:39 -0400 Message-Id: <9CA92F89-880D-46A8-835C-F4E93722BEE2@cs.umd.edu> From: Khoo Yit Phang To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v924) Subject: Problem with class method and polymorphic variants Date: Tue, 24 Jun 2008 14:17:36 -0400 Cc: Khoo Yit Phang X-Mailer: Apple Mail (2.924) X-CSD-MailScanner-Information: Please email staff@cs.umd.edu for more information X-CSD-MailScanner: Found to be clean X-CSD-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=0.131, required 5, ALL_TRUSTED -1.80, TVD_RCVD_IP 1.93) X-CSD-MailScanner-From: khooyp@cs.umd.edu X-Spam: no; 0.00; variants:01 ocaml:01 ocamlc:01 ocaml:01 toplevel:01 bug:01 type-checker:01 ocamlc:01 polymorphic:01 compile:01 constraint:01 constraint:01 int:01 int:01 inferred:02 Hi, I discovered that the attached snippet of Ocaml does not compile in ocamlc, but does work in the ocaml toplevel (tested in v3.10.0 and 3.10.2). Removing anything (except the :int annotation) causes the error to go away. Is it a bug in the type-checker? # cat polymorphic-variants-methods-bug.ml class ['a] c (a : 'a) = object (s) method s = s method d : int = match a with `A b -> b#num end # ocamlc polymorphic-variants-methods-bug.ml The implementation polymorphic-variants-methods-bug.ml does not match the interface (inferred signature): Type declarations do not match: type 'a c = < d : int; s : 'a c > constraint 'a = [< `A of < num : int; .. > & < num : int; .. > ] is not included in type 'a c = < d : int; s : 'a c > constraint 'a = [< `A of < num : int; .. > & < num : int; .. > & < num : int; .. > ] #ocamlc -i polymorphic-variants-methods-bug.ml class ['a] c : 'a -> object ('b) constraint 'a = [< `A of < num : int; .. > ] method d : int method s : 'b end Yit June 24, 2008