PR#5668: print using the syntax "let f x y z = ..." only when the pattern is an identifier

This form is incorrect when the pattern is not an identifier.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12656 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Jérémie Dimino 2012-07-04 16:29:35 +00:00
parent 07a3f52d76
commit 6d308ad574
1 changed files with 9 additions and 6 deletions

View File

@ -301,16 +301,19 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct
| <:binding< $b1$ and $b2$ >> ->
do { o#binding f b1; pp f o#andsep; o#binding f b2 }
| <:binding< $p$ = $e$ >> ->
let (pl, e) =
let (pl, e') =
match p with
[ <:patt< ($_$ : $_$) >> -> ([], e)
| _ -> expr_fun_args e ] in
match (p, e) with
[ (<:patt< $lid:_$ >>, <:expr< ($e$ : $t$) >>) ->
match (p, e') with
[ (<:patt< $lid:_$ >>, <:expr< ($e'$ : $t$) >>) ->
pp f "%a :@ %a =@ %a"
(list o#fun_binding "@ ") [`patt p::pl] o#ctyp t o#expr e
| _ -> pp f "%a @[<0>%a=@]@ %a" o#simple_patt
p (list' o#fun_binding "" "@ ") pl o#expr e ]
(list o#fun_binding "@ ") [`patt p::pl] o#ctyp t o#expr e'
| (<:patt< $lid:_$ >>, _) ->
pp f "%a @[<0>%a=@]@ %a" o#simple_patt
p (list' o#fun_binding "" "@ ") pl o#expr e'
| _ ->
pp f "%a =@ %a" o#simple_patt p o#expr e ]
| <:binding< $anti:s$ >> -> o#anti f s ];
method record_binding f bi =