Skip to content
This repository
Browse code

Handling 4.02 'match with exception' syntax

Closes #129
  • Loading branch information...
commit 9bb8af1773873068704ec50f3ce3ff96c58a28be 1 parent b85cb33
Louis Gesbert AltGr authored
6 src/indentBlock.ml
@@ -673,7 +673,11 @@ let rec update_path config block stream tok =
673 673 match tok.token with
674 674 | SEMISEMI -> append KUnknown L ~pad:0 (unwind_top block.path)
675 675 | INCLUDE -> append KInclude L (unwind_top block.path)
676   - | EXCEPTION -> append KException L (unwind_top block.path)
  676 + | EXCEPTION ->
  677 + let p = unwind (function KExpr _ -> false | _ -> true) block.path in
  678 + (match p with
  679 + | {kind=KWith KMatch|KBar KMatch}::_ -> append expr_atom L block.path
  680 + | _ -> append KException L (unwind_top block.path))
677 681 | BEGIN -> open_paren KBegin block.path
678 682 | OBJECT -> append KObject L block.path
679 683 | VAL -> append KVal L (unwind_top block.path)
4 tests/failing.html
@@ -2,7 +2,7 @@
2 2 "http://www.w3.org/TR/REC-html40/loose.dtd">
3 3 <html>
4 4 <head>
5   - <title>Failing tests, ocp-indent version 1.4.1+11 (2014-06-11)</title>
  5 + <title>Failing tests, ocp-indent version 1.4.1+17 (2014-06-11)</title>
6 6 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
7 7 <style>
8 8 TABLE { border-collapse: collapse; border-spacing: 0px; margin: auto; }
@@ -16,7 +16,7 @@
16 16 </style>
17 17 </head>
18 18 <body>
19   -<h1>Failing tests, ocp-indent version 1.4.1+11 (2014-06-11)</h1>
  19 +<h1>Failing tests, ocp-indent version 1.4.1+17 (2014-06-11)</h1>
20 20 <div>
21 21 <h2>Differences in js-args.ml</h2>
22 22 <table>
17 tests/passing/embedded-match.ml
@@ -13,3 +13,20 @@ let f x =
13 13 1
14 14 else
15 15 0
  16 +
  17 +let f x =
  18 + match x with
  19 + | A -> true
  20 + | B ->
  21 + false
  22 + | exception
  23 + Not_found ->
  24 + false
  25 + | C -> true
  26 + | exception (Failure _ | Invalid_argument _) ->
  27 + true
  28 + | exception (A | B) | exception B.Err
  29 + | exception C.Types.Xxx "someparam" ->
  30 + false
  31 +
  32 +exception MyExn of string

1 comment on commit 9bb8af1

alainfrisch

Are you sure you want to keep this patch? It does work e.g. with

let f x =
  match x with
  | A x ->
      x
  | A | exception x-> 
  x
                | B x ->
                  x
Please sign in to comment.
Something went wrong with that request. Please try again.