From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id A0DDCBB91 for ; Sun, 23 Jan 2005 22:43:04 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j0NLh4JX006182 for ; Sun, 23 Jan 2005 22:43:04 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA07219 for ; Sun, 23 Jan 2005 22:43:03 +0100 (MET) Received: from postfix4-1.free.fr (postfix4-1.free.fr [213.228.0.62]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0NLh3Jr008267 for ; Sun, 23 Jan 2005 22:43:03 +0100 Received: from warp (chateaudeau-4-82-225-176-25.fbx.proxad.net [82.225.176.25]) by postfix4-1.free.fr (Postfix) with SMTP id 2AC0127135C; Sun, 23 Jan 2005 22:43:01 +0100 (CET) Message-ID: <001a01c50194$b7845da0$474cfea9@warp> From: "Nicolas Cannasse" To: , "Richard Jones" References: <20050123211112.GA14067@furbychan.cocan.org> Subject: Re: [Caml-list] Strange syntax error Date: Sun, 23 Jan 2005 22:44:27 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Miltered: at nez-perce with ID 41F41A68.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41F41A67.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; cannasse:01 warplayer:01 caml-list:01 syntax:01 failwith:01 syntax:01 failwith:01 ocaml:01 parsing:01 bug:01 cannasse:01 compiles:01 logical:01 patterns:02 patterns:02 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: > The following compiles fine: > > type t = { keyword : string; cost : float option; } > > let f = > function > | { keyword = keyword } when keyword.[0] = '-' -> keyword > | { keyword = keyword; cost = None } -> keyword > | _ -> failwith "whatever" > > But this, which surely is equivalent, fails with a syntax error at the > second '|' character: > > type t = { keyword : string; cost : float option; } > > let f = > function > | { keyword = keyword } when keyword.[0] = '-' (* -> keyword *) > | { keyword = keyword; cost = None } -> keyword > | _ -> failwith "whatever" > > OCaml 3.08.1. > > Is this a parsing bug? > > Rich. I guess you can't have a "when" clause between two patterns, that sounds logical since it applies to all patterns in the same "group". Nicolas Cannasse