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=AWL,DRUGS_MUSCLE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 97F05BBAF for ; Wed, 25 Feb 2009 17:02:19 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqkBAIT6pElCbwQZk2dsb2JhbACUZAEBAQEJCQoJEQTENoQRBg X-IronPort-AV: E=Sophos;i="4.38,265,1233529200"; d="scan'208";a="24665719" Received: from out1.smtp.messagingengine.com ([66.111.4.25]) by mail1-smtp-roc.national.inria.fr with ESMTP; 25 Feb 2009 17:02:18 +0100 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 9DC5D2A3E14; Wed, 25 Feb 2009 11:02:17 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 25 Feb 2009 11:02:17 -0500 X-Sasl-enc: qIP5GSfG6OtjyNlTdaM/pB+aC8Q/e4mS6mmZvtPL8yx0 1235577737 Received: from [192.168.1.10] (ALyon-157-1-38-229.w86-219.abo.wanadoo.fr [86.219.245.229]) by mail.messagingengine.com (Postfix) with ESMTPSA id E1FCB26F7C; Wed, 25 Feb 2009 11:02:16 -0500 (EST) Message-ID: <49A56AF2.6090501@ens-lyon.org> Date: Wed, 25 Feb 2009 16:59:46 +0100 From: Martin Jambon User-Agent: Thunderbird 2.0.0.17 (X11/20081008) MIME-Version: 1.0 To: David Allsopp Cc: OCaml List Subject: Re: [Caml-list] Using camlp4 syntax extensions in the top-level References: <001601c9975d$1f633d80$5e29b880$@com> In-Reply-To: <001601c9975d$1f633d80$5e29b880$@com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ens-lyon:01 camlp:01 syntax:01 toplevel:01 ocaml:01 mingw:01 findlib:01 camlp:01 ocaml:01 lib:01 dynlink:01 lib:01 site-lib:01 pcre:01 site-lib:01 David Allsopp wrote: > I'm trying to use json-static in the toplevel (OCaml 3.11.0 / MinGW / > findlib 1.2.4) but I'm getting an error message: > > # #camlp4o;; > C:\Dev\OCaml\lib\dynlink.cma: loaded > C:\Dev\OCaml\lib\camlp4: added to search path > C:\Dev\OCaml\lib\camlp4\camlp4o.cma: loaded > Camlp4 Parsing version 3.11.0 > > # #require "json-static";; > c:\Dev\OCaml\lib\site-lib\pcre: added to search path > c:\Dev\OCaml\lib\site-lib\pcre\pcre.cma: loaded > c:\Dev\OCaml\lib\site-lib\netsys: added to search path > c:\Dev\OCaml\lib\site-lib\netsys\netsys.cma: loaded > c:\Dev\OCaml\lib\site-lib\netstring: added to search path > c:\Dev\OCaml\lib\site-lib\netstring\netstring.cma: loaded > c:\Dev\OCaml\lib\site-lib\netstring\netstring_top.cmo: loaded > c:\Dev\OCaml\lib\site-lib\netstring\netaccel.cma: loaded > c:\Dev\OCaml\lib\site-lib\netstring\netaccel_link.cmo: loaded > c:\Dev\OCaml\lib\site-lib\json-wheel: added to search path > c:\Dev\OCaml\lib\site-lib\json-wheel\jsonwheel.cma: loaded > c:\Dev\OCaml\lib\site-lib\json-static: added to search path > c:\Dev\OCaml\lib\site-lib\json-static\pa_json_static.cmo: loaded > # type json point = < x: number; y: number > > and coords = point array;; > Assertion failed, file "camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml", line > 795, char 11 > > I can build the example using ocamlc with no problems - I just don't seem to > be able to do it interactively in the toplevel. Should I be able to? In theory yes. It was working fine with the old camlp4 and ocaml 3.09.3. The piece of code from which the failed assertion comes from is the following (camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml version 3.11.0, line 795, char 11): and mktype_decl x acc = match x with [ <:ctyp< $x$ and $y$ >> -> mktype_decl x (mktype_decl y acc) | Ast.TyDcl _ c tl td cl -> let cl = List.map (fun (t1, t2) -> let loc = Loc.merge (loc_of_ctyp t1) (loc_of_ctyp t2) in (ctyp t1, ctyp t2, mkloc loc)) cl in [(c, type_decl (List.fold_right type_parameters tl []) cl td) :: acc] | _ -> assert False ] I had no idea of this problem. Even a very simple example fails: # type json t = int;; Assertion failed, file "camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml", line 795, char 11 The pretty-printed code produced by camlp4o is the following: $ cat toto.ml type json t = int $ camlp4o -printer o -I /home/martin/godi3110/lib/ocaml/pkg-lib/json-static -parser pa_json_static.cmo toto.ml type t = int let __json_static_error obj msg = let m = 400 in let s = Json_io.string_of_json obj in let obj_string = if (String.length s) > m then (String.sub s 0 (m - 4)) ^ " ..." else s in Json_type.json_error (msg ^ (": " ^ obj_string)) let rec (t_of_json : Json_type.t -> t) = fun x -> Json_type.Browse.int x let rec (json_of_t : t -> Json_type.t) = fun x -> Json_type.Build.int x There may be a workaround. It needs more investigation. Thanks for reporting the problem. Martin -- http://mjambon.com/