Commits

Anonymous committed 2f1e9c2

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@12656f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

Comments (0)

Files changed (1)

camlp4/Camlp4/Printers/OCaml.ml

       | <: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 =
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.