summaryrefslogtreecommitdiff
blob: 630d6bfff3fc54749a51fdf1a2647b5e42836185 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
diff -uNr ppx_driver-113.33.00/_oasis ppx_driver-113.33.00+4.03/_oasis
--- ppx_driver-113.33.00/_oasis	2016-03-09 16:44:54.000000000 +0100
+++ ppx_driver-113.33.00+4.03/_oasis	2016-03-22 15:13:50.000000000 +0100
@@ -1,8 +1,8 @@
 OASISFormat:      0.4
-OCamlVersion:     >= 4.02.3
+OCamlVersion:     >= 4.03.0
 FindlibVersion:   >= 1.3.2
 Name:             ppx_driver
-Version:          113.33.00
+Version:          113.33.00+4.03
 Synopsis:         Feature-full driver for OCaml AST transformers
 Authors:          Jane Street Group, LLC <opensource@janestreet.com>
 Copyrights:       (C) 2015-2016 Jane Street Group LLC <opensource@janestreet.com>
diff -uNr ppx_driver-113.33.00/opam ppx_driver-113.33.00+4.03/opam
--- ppx_driver-113.33.00/opam	2016-03-18 12:08:01.000000000 +0100
+++ ppx_driver-113.33.00+4.03/opam	2016-03-22 17:51:36.000000000 +0100
@@ -16,4 +16,4 @@
   "ppx_core"
   "ppx_optcomp"
 ]
-available: [ ocaml-version >= "4.02.3" ]
+available: [ ocaml-version >= "4.03.0" ]
diff -uNr ppx_driver-113.33.00/src/ppx_driver.ml ppx_driver-113.33.00+4.03/src/ppx_driver.ml
--- ppx_driver-113.33.00/src/ppx_driver.ml	2016-03-09 16:44:54.000000000 +0100
+++ ppx_driver-113.33.00+4.03/src/ppx_driver.ml	2016-03-22 15:13:50.000000000 +0100
@@ -111,6 +111,24 @@
   |> fst
 ;;
 
+let remove_empty_lets = object
+  inherit Ast_traverse.map as super
+
+  method! structure_item st =
+    let st = super#structure_item st in
+    match st.pstr_desc with
+    | Pstr_value (_, []) ->
+      let (module B) = Ast_builder.make st.pstr_loc in
+      B.pstr_value Nonrecursive [B.value_binding ~pat:B.punit ~expr:B.eunit]
+    | _ -> st
+
+  method! expression e =
+    let e = super#expression e in
+    match e.pexp_desc with
+    | Pexp_let (_, [], e) -> e
+    | _ -> e
+end
+
 let map_structure st =
   let st =
     if !perform_checks then begin
@@ -123,6 +141,7 @@
     apply_transforms st ~field:(fun (ct : Transform.t) -> ct.impl)
       ~dropped_so_far:Attribute.dropped_so_far_structure
   in
+  let st = remove_empty_lets#structure st in
   if !perform_checks then begin
     Attribute.check_unused#structure st;
     Extension.check_unused#structure st;
@@ -143,6 +162,7 @@
     apply_transforms sg ~field:(fun ct -> ct.intf)
       ~dropped_so_far:Attribute.dropped_so_far_signature
   in
+  let sg = remove_empty_lets#signature sg in
   if !perform_checks then begin
     Attribute.check_unused#signature sg;
     Extension.check_unused#signature sg;