|
1 | | -let add_promise_type ?(loc=Location.none) ~async (result : Parsetree.expression) = |
| 1 | +let add_promise_type ?(loc = Location.none) ~async |
| 2 | + (result : Parsetree.expression) = |
2 | 3 | if async then |
3 | 4 | let unsafe_async = |
4 | 5 | Ast_helper.Exp.ident ~loc |
5 | | - { txt = Ldot (Ldot (Lident "Js", "Promise"), "unsafe_async"); loc } |
| 6 | + {txt = Ldot (Ldot (Lident "Js", "Promise"), "unsafe_async"); loc} |
6 | 7 | in |
7 | | - Ast_helper.Exp.apply ~loc unsafe_async [ (Nolabel, result) ] |
| 8 | + Ast_helper.Exp.apply ~loc unsafe_async [(Nolabel, result)] |
8 | 9 | else result |
9 | 10 |
|
10 | 11 | let add_async_attribute ~async (body : Parsetree.expression) = |
11 | 12 | if async then |
12 | 13 | { |
13 | 14 | body with |
14 | 15 | pexp_attributes = |
15 | | - ({ txt = "res.async"; loc = Location.none }, PStr []) |
| 16 | + ({txt = "res.async"; loc = Location.none}, PStr []) |
16 | 17 | :: body.pexp_attributes; |
17 | 18 | } |
18 | 19 | else body |
19 | 20 |
|
20 | 21 | let rec add_promise_to_result ~loc (e : Parsetree.expression) = |
21 | 22 | match e.pexp_desc with |
22 | 23 | | Pexp_fun (label, eo, pat, body) -> |
23 | | - let body = add_promise_to_result ~loc body in |
24 | | - { e with pexp_desc = Pexp_fun (label, eo, pat, body) } |
| 24 | + let body = add_promise_to_result ~loc body in |
| 25 | + {e with pexp_desc = Pexp_fun (label, eo, pat, body)} |
25 | 26 | | _ -> add_promise_type ~loc ~async:true e |
26 | 27 |
|
27 | 28 | let make_function_async ~async (e : Parsetree.expression) = |
|
0 commit comments