File tree Expand file tree Collapse file tree 4 files changed +16
-12
lines changed
tests/syntax_tests/data/parsing/grammar/expressions/expected Expand file tree Collapse file tree 4 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 11let has_async_payload attrs =
22 Ext_list. exists attrs (fun ({Location. txt} , _ ) -> txt = " res.async" )
33
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+
410let add_async_attribute ~async (body : Parsetree.expression ) =
511 let add (exp : Parsetree.expression ) =
612 if has_async_payload exp.pexp_attributes then exp
@@ -20,7 +26,7 @@ let add_async_attribute ~async (body : Parsetree.expression) =
2026 | Pexp_fun _ -> add exp
2127 | _ -> exp
2228 in
23- add ( add_to_fun body)
29+ add_to_fun body
2430 else body
2531
2632let 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 =
954954 let binding_wrapper, has_forward_ref, expression =
955955 modified_binding ~binding_loc ~binding_pat_loc ~fn_name binding
956956 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
960958 let named_arg_list, newtypes, _typeConstraints =
961959 recursively_transform_named_args_for_make
962960 (modified_binding_old binding)
@@ -1190,7 +1188,7 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
11901188 in
11911189
11921190 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
11941192 in
11951193
11961194 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 =
166166 | NewTypes of {attrs : Parsetree .attributes ; locs : string Asttypes .loc list }
167167
168168let 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
170170 let rec collect_params ~n_fun ~params expr =
171171 match expr with
172172 | {
Original file line number Diff line number Diff line change @@ -35,15 +35,15 @@ let ex4 = (((foo.bar).baz)[@res.await ])
3535let attr1 = ((fun [arity:1]x -> x + 1)[@res.async ][@a ])
3636let attr2 = ((fun (type a) ->
3737 ((fun [arity:1]() -> fun (type b) -> fun (type c) -> fun [arity:1]x -> 3)
38- [@res.async ]))[@res.async ][@ a ])
38+ [@res.async ]))[@a ])
3939let 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 ]))
4242 [@a ])
4343let attr4 = ((fun (type a) ->
4444 fun [arity:1]() -> ((fun (type b) -> fun (type c) -> ((fun [arity:1]x -> 3)
45- [@res.async ]))[@res.async ][@ b ]))
45+ [@res.async ]))[@b ]))
4646 [@a ])
4747let (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