File tree 4 files changed +16
-12
lines changed
tests/syntax_tests/data/parsing/grammar/expressions/expected
4 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 1
1
let has_async_payload attrs =
2
2
Ext_list. exists attrs (fun ({Location. txt} , _ ) -> txt = " res.async" )
3
3
4
+ let rec dig_async_payload_from_function (expr : Parsetree.expression ) =
5
+ match expr.pexp_desc with
6
+ | Pexp_fun _ -> has_async_payload expr.pexp_attributes
7
+ | Pexp_newtype (_ , body ) -> dig_async_payload_from_function body
8
+ | _ -> false
9
+
4
10
let add_async_attribute ~async (body : Parsetree.expression ) =
5
11
let add (exp : Parsetree.expression ) =
6
12
if has_async_payload exp.pexp_attributes then exp
@@ -20,7 +26,7 @@ let add_async_attribute ~async (body : Parsetree.expression) =
20
26
| Pexp_fun _ -> add exp
21
27
| _ -> exp
22
28
in
23
- add ( add_to_fun body)
29
+ add_to_fun body
24
30
else body
25
31
26
32
let add_promise_type ?(loc = Location. none) ~async
Original file line number Diff line number Diff line change @@ -954,9 +954,7 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
954
954
let binding_wrapper, has_forward_ref, expression =
955
955
modified_binding ~binding_loc ~binding_pat_loc ~fn_name binding
956
956
in
957
- let is_async =
958
- Ast_async. has_async_payload binding.pvb_expr.pexp_attributes
959
- in
957
+ let is_async = Ast_async. dig_async_payload_from_function binding.pvb_expr in
960
958
let named_arg_list, newtypes, _typeConstraints =
961
959
recursively_transform_named_args_for_make
962
960
(modified_binding_old binding)
@@ -1190,7 +1188,7 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
1190
1188
in
1191
1189
1192
1190
let is_async =
1193
- Ast_async. has_async_payload modified_binding.pvb_expr.pexp_attributes
1191
+ Ast_async. dig_async_payload_from_function modified_binding.pvb_expr
1194
1192
in
1195
1193
1196
1194
let make_new_binding ~loc ~full_module_name binding =
Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ type fun_param_kind =
166
166
| NewTypes of {attrs : Parsetree .attributes ; locs : string Asttypes .loc list }
167
167
168
168
let fun_expr expr_ =
169
- let async = Ast_async. has_async_payload expr_.pexp_attributes in
169
+ let async = Ast_async. dig_async_payload_from_function expr_ in
170
170
let rec collect_params ~n_fun ~params expr =
171
171
match expr with
172
172
| {
Original file line number Diff line number Diff line change @@ -35,15 +35,15 @@ let ex4 = (((foo.bar).baz)[@res.await ])
35
35
let attr1 = ((fun [arity:1]x -> x + 1)[@res.async ][@a ])
36
36
let attr2 = ((fun (type a) ->
37
37
((fun [arity:1]() -> fun (type b) -> fun (type c) -> fun [arity:1]x -> 3)
38
- [@res.async ]))[@res.async ][@ a ])
38
+ [@res.async ]))[@a ])
39
39
let attr3 = ((fun (type a) ->
40
- fun [arity:1]() -> (( fun (type b) -> fun (type c) -> ((fun [arity:1]x -> 3)
41
- [@res.async ]))[@res.async ]))
40
+ fun [arity:1]() -> fun (type b) -> fun (type c) -> ((fun [arity:1]x -> 3)
41
+ [@res.async ]))
42
42
[@a ])
43
43
let attr4 = ((fun (type a) ->
44
44
fun [arity:1]() -> ((fun (type b) -> fun (type c) -> ((fun [arity:1]x -> 3)
45
- [@res.async ]))[@res.async ][@ b ]))
45
+ [@res.async ]))[@b ]))
46
46
[@a ])
47
47
let (attr5 : int) = ((fun (type a) -> fun (type b) -> fun (type c) ->
48
- ((fun [arity:1]() -> fun [arity:1](x : a) -> x)[@res.async ]))
49
- [@res.async ][@a ][@ b ])
48
+ ((fun [arity:1]() -> fun [arity:1](x : a) -> x)[@res.async ]))[@a ]
49
+ [@b ])
You can’t perform that action at this time.
0 commit comments