| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] |
| ID | Project | Category | View Status | Date Submitted | Last Update |
| 0004928 | OCaml | Camlp4 | public | 2009-11-25 16:09 | 2012-09-25 20:06 |
|
| Reporter | ygrek | |
| Assigned To | xclerc | |
| Priority | normal | Severity | major | Reproducibility | always |
| Status | closed | Resolution | fixed | |
| Platform | | OS | | OS Version | |
| Product Version | 3.11.1 | |
| Target Version | | Fixed in Version | 3.12.1+dev | |
|
| Summary | 0004928: wrong printing of method specifications |
| Description | Printers.OCaml.print_implem adds ;; after each method specification. This is not a valid OCaml syntax.
`-pp camlp4o` accepts such syntax. Probably this is another bug.
|
| Additional Information | $ cat q.ml
open Camlp4.PreCast
let _loc = Loc.mk "<string>"
let make s = <:str_item< class $lid:s$ = object method name = $str:s$ end >>
let () = Printers.OCaml.print_implem (make "hello")
$ ocaml dynlink.cma camlp4of.cma -init q.ml
Objective Caml version 3.11.1
Camlp4 Parsing version 3.11.1
class hello = object method name = "hello";; end;;
|
| Tags | No tags attached. |
|
| Attached Files | camlp4_method.patch [^] (4,599 bytes) 2009-12-03 17:57 [Show Content] [Hide Content]diff -ur ocaml-3.11.1/camlp4/Camlp4/Printers/OCaml.ml ocaml-3.11.1.patched/camlp4/Camlp4/Printers/OCaml.ml
--- ocaml-3.11.1/camlp4/Camlp4/Printers/OCaml.ml 2008-10-27 15:03:56.000000000 +0100
+++ ocaml-3.11.1.patched/camlp4/Camlp4/Printers/OCaml.ml 2009-12-03 17:52:12.000000000 +0100
@@ -165,6 +165,7 @@
method reset = {< pipe = False; semi = False >};
value semisep : sep = ";;";
+ value sep : sep = "";
value andsep : sep = "@]@ @[<2>and@ ";
value value_val = "val";
value value_let = "let";
@@ -173,6 +174,7 @@
value var_conversion = False;
method semisep = semisep;
+ (* method sep = sep; *)
method set_semisep s = {< semisep = s >};
method set_comments b = {< mode = if b then `comments else `no_comments >};
method set_loc_and_comments = {< mode = `loc_and_comments >};
@@ -956,21 +958,21 @@
| <:class_sig_item< $csg1$; $csg2$ >> ->
do { o#class_sig_item f csg1; cut f; o#class_sig_item f csg2 }
| <:class_sig_item< constraint $t1$ = $t2$ >> ->
- pp f "@[<2>constraint@ %a =@ %a%(%)@]" o#ctyp t1 o#ctyp t2 semisep
+ pp f "@[<2>constraint@ %a =@ %a%(%)@]" o#ctyp t1 o#ctyp t2 sep
| <:class_sig_item< inherit $ct$ >> ->
- pp f "@[<2>inherit@ %a%(%)@]" o#class_type ct semisep
+ pp f "@[<2>inherit@ %a%(%)@]" o#class_type ct sep
| <:class_sig_item< method $private:pr$ $s$ : $t$ >> ->
pp f "@[<2>method %a%a :@ %a%(%)@]" o#private_flag pr o#var s
- o#ctyp t semisep
+ o#ctyp t sep
| <:class_sig_item< method virtual $private:pr$ $s$ : $t$ >> ->
pp f "@[<2>method virtual %a%a :@ %a%(%)@]"
- o#private_flag pr o#var s o#ctyp t semisep
+ o#private_flag pr o#var s o#ctyp t sep
| <:class_sig_item< value $mutable:mu$ $virtual:vi$ $s$ : $t$ >> ->
pp f "@[<2>%s %a%a%a :@ %a%(%)@]"
value_val o#mutable_flag mu o#virtual_flag vi o#var s o#ctyp t
- semisep
+ sep
| <:class_sig_item< $anti:s$ >> ->
- pp f "%a%(%)" o#anti s semisep ];
+ pp f "%a%(%)" o#anti s sep ];
method class_str_item f cst =
let () = o#node f cst Ast.loc_of_class_str_item in
@@ -982,30 +984,30 @@
| <:class_str_item< $cst1$; $cst2$ >> ->
do { o#class_str_item f cst1; cut f; o#class_str_item f cst2 }
| <:class_str_item< constraint $t1$ = $t2$ >> ->
- pp f "@[<2>constraint %a =@ %a%(%)@]" o#ctyp t1 o#ctyp t2 semisep
+ pp f "@[<2>constraint %a =@ %a%(%)@]" o#ctyp t1 o#ctyp t2 sep
| <:class_str_item< inherit $ce$ >> ->
- pp f "@[<2>inherit@ %a%(%)@]" o#class_expr ce semisep
+ pp f "@[<2>inherit@ %a%(%)@]" o#class_expr ce sep
| <:class_str_item< inherit $ce$ as $lid:s$ >> ->
- pp f "@[<2>inherit@ %a as@ %a%(%)@]" o#class_expr ce o#var s semisep
+ pp f "@[<2>inherit@ %a as@ %a%(%)@]" o#class_expr ce o#var s sep
| <:class_str_item< initializer $e$ >> ->
- pp f "@[<2>initializer@ %a%(%)@]" o#expr e semisep
+ pp f "@[<2>initializer@ %a%(%)@]" o#expr e sep
| <:class_str_item< method $private:pr$ $s$ = $e$ >> ->
pp f "@[<2>method %a%a =@ %a%(%)@]"
- o#private_flag pr o#var s o#expr e semisep
+ o#private_flag pr o#var s o#expr e sep
| <:class_str_item< method $private:pr$ $s$ : $t$ = $e$ >> ->
pp f "@[<2>method %a%a :@ %a =@ %a%(%)@]"
- o#private_flag pr o#var s o#ctyp t o#expr e semisep
+ o#private_flag pr o#var s o#ctyp t o#expr e sep
| <:class_str_item< method virtual $private:pr$ $s$ : $t$ >> ->
pp f "@[<2>method virtual@ %a%a :@ %a%(%)@]"
- o#private_flag pr o#var s o#ctyp t semisep
+ o#private_flag pr o#var s o#ctyp t sep
| <:class_str_item< value virtual $mutable:mu$ $s$ : $t$ >> ->
pp f "@[<2>%s virtual %a%a :@ %a%(%)@]"
- value_val o#mutable_flag mu o#var s o#ctyp t semisep
+ value_val o#mutable_flag mu o#var s o#ctyp t sep
| <:class_str_item< value $mutable:mu$ $s$ = $e$ >> ->
pp f "@[<2>%s %a%a =@ %a%(%)@]"
- value_val o#mutable_flag mu o#var s o#expr e semisep
+ value_val o#mutable_flag mu o#var s o#expr e sep
| <:class_str_item< $anti:s$ >> ->
- pp f "%a%(%)" o#anti s semisep ];
+ pp f "%a%(%)" o#anti s sep ];
method implem f st =
match st with
|
|