Skip to content

Commit

Permalink
PPX: remove -no-debug option
Browse files Browse the repository at this point in the history
Resolves #528.
  • Loading branch information
aantron committed Dec 15, 2019
1 parent 2f3edad commit 97572d4
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions src/ppx/ppx_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,12 @@ let lwt_prefix = "__ppx_lwt_"

(** {2 Here we go!} *)

let debug = ref true
let sequence = ref true
let strict_seq = ref true

let used_no_debug_option = ref false
let used_no_sequence_option = ref false
let used_no_strict_sequence_option = ref false

let no_debug_option () =
debug := false;
used_no_debug_option := true

let no_sequence_option () =
sequence := false;
used_no_sequence_option := true
Expand Down Expand Up @@ -82,16 +76,13 @@ let gen_binds e_loc l e =
[%expr (fun [%p binding.pvb_pat] -> [%e aux (i+1) t])] [@metaloc e_loc]
in
let new_exp =
if !debug then
[%expr
let module Reraise = struct external reraise : exn -> 'a = "%reraise" end in
Lwt.backtrace_bind
(fun exn -> try Reraise.reraise exn with exn -> exn)
[%e name]
[%e fun_]
] [@metaloc e_loc]
else
[%expr Lwt.bind [%e name] [%e fun_]] [@metaloc e_loc]
in
{ new_exp with pexp_attributes = binding.pvb_attributes }
in aux 0 l
Expand All @@ -102,16 +93,13 @@ let gen_binds e_loc l e =
let lwt_sequence mapper ~exp ~lhs ~rhs ~ext_loc =
let pat= [%pat? ()][@metaloc ext_loc] in
let lhs, rhs = mapper.expr mapper lhs, mapper.expr mapper rhs in
(if !debug then
[%expr
let module Reraise = struct external reraise : exn -> 'a = "%reraise" end in
Lwt.backtrace_bind
(fun exn -> try Reraise.reraise exn with exn -> exn)
[%e lhs]
(fun [%p pat] -> [%e rhs])
]
else
[%expr Lwt.bind [%e lhs] (fun [%p pat] -> [%e rhs])])
[@metaloc exp.pexp_loc]

(** For expressions only *)
Expand Down Expand Up @@ -233,7 +221,6 @@ let lwt_expression mapper exp attributes ext_loc =
| Pexp_try (expr, cases) ->
let cases = add_wildcard_case cases in
let new_exp =
if !debug then
[%expr
let module Reraise = struct external reraise : exn -> 'a = "%reraise" end in
Lwt.backtrace_catch
Expand All @@ -242,9 +229,6 @@ let lwt_expression mapper exp attributes ext_loc =
[%e Exp.function_ cases]
]
[@metaloc !default_loc]
else
[%expr Lwt.catch (fun () -> [%e expr]) [%e Exp.function_ cases]]
[@metaloc !default_loc]
in
Some (mapper.expr mapper { new_exp with pexp_attributes })

Expand Down Expand Up @@ -302,9 +286,6 @@ let mapper =
|> warn_if (!used_no_sequence_option)
("-no-sequence is a deprecated Lwt PPX option\n" ^
" See https://github.com/ocsigen/lwt/issues/495")
|> warn_if (!used_no_debug_option)
("-no-debug is a deprecated Lwt PPX option\n" ^
" See https://github.com/ocsigen/lwt/issues/528")
end
end;

Expand All @@ -325,7 +306,6 @@ let mapper =
| [%expr [%e? exp ] [%finally [%e? finally]] ]
| [%expr [%e? exp ] [%lwt.finally [%e? finally]] ] ->
let new_exp =
if !debug then
[%expr
let module Reraise = struct external reraise : exn -> 'a = "%reraise" end in
Lwt.backtrace_finalize
Expand All @@ -334,9 +314,6 @@ let mapper =
(fun () -> [%e finally])
]
[@metaloc !default_loc]
else
[%expr Lwt.finalize (fun () -> [%e exp]) (fun () -> [%e finally])]
[@metaloc !default_loc]
in
mapper.expr mapper
{ new_exp with
Expand Down Expand Up @@ -374,10 +351,6 @@ let mapper =

let args =
Arg.([
"-no-debug",
Unit no_debug_option,
" disable debug mode (deprecated)";

"-no-sequence",
Unit no_sequence_option,
" has no effect (deprecated)";
Expand Down

0 comments on commit 97572d4

Please sign in to comment.