File tree 7 files changed +37
-8
lines changed
7 files changed +37
-8
lines changed Original file line number Diff line number Diff line change 15
15
#### :nail_care : Polish
16
16
17
17
- Add the gap property to jsxDOMStyle https://github.com/rescript-lang/rescript-compiler/pull/5956
18
+
19
+ #### :bug : Bug Fix
18
20
- Fix issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/syntax/pull/730
19
21
- Fix issue where uncurried functions were incorrectly converting the type of a prop given as a default value to curried https://github.com/rescript-lang/syntax/pull/731
22
+ - Fix issue with nested async functions, where the inner function would be emitted without ` async `
20
23
21
24
# 10.1.2
22
25
Original file line number Diff line number Diff line change @@ -681,6 +681,8 @@ let rec cut n l =
681
681
682
682
let try_ids = Hashtbl. create 8
683
683
684
+ let has_async_attribute exp = exp.exp_attributes |> List. exists (fun ({txt} , _payload ) -> txt = " res.async" )
685
+
684
686
let rec transl_exp e =
685
687
List. iter (Translattribute. check_attribute e) e.exp_attributes;
686
688
transl_exp0 e
@@ -695,7 +697,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda =
695
697
| Texp_let (rec_flag , pat_expr_list , body ) ->
696
698
transl_let rec_flag pat_expr_list (transl_exp body)
697
699
| Texp_function { arg_label = _ ; param; cases; partial } ->
698
- let async = e.exp_attributes |> List. exists ( fun ( {txt} , _payload ) -> txt = " res.async " ) in
700
+ let async = has_async_attribute e in
699
701
let params, body, return_unit =
700
702
let pl = push_defaults e.exp_loc [] cases partial in
701
703
transl_function e.exp_loc partial param pl
@@ -1021,7 +1023,7 @@ and transl_function loc partial param cases =
1021
1023
} as exp;
1022
1024
};
1023
1025
]
1024
- when Parmatch. inactive ~partial pat ->
1026
+ when Parmatch. inactive ~partial pat && not (exp |> has_async_attribute) ->
1025
1027
let params, body, return_unit =
1026
1028
transl_function exp.exp_loc partial' param' cases
1027
1029
in
Original file line number Diff line number Diff line change @@ -38,10 +38,24 @@ async function broken$1(someAsyncFunction) {
38
38
39
39
var broken$2 = broken$1 ;
40
40
41
+ function nested1 ( param ) {
42
+ return async function ( y ) {
43
+ return await y ;
44
+ } ;
45
+ }
46
+
47
+ async function nested2 ( param ) {
48
+ return async function ( y ) {
49
+ return await y ;
50
+ } ;
51
+ }
52
+
41
53
exports . willBeInlined = willBeInlined ;
42
54
exports . inlined = inlined ;
43
55
exports . wrapSomethingAsync = wrapSomethingAsync ;
44
56
exports . wrapSomethingAsync2 = wrapSomethingAsync2 ;
45
57
exports . M = M ;
46
58
exports . broken = broken$2 ;
59
+ exports . nested1 = nested1 ;
60
+ exports . nested2 = nested2 ;
47
61
/* inlined Not a pure module */
Original file line number Diff line number Diff line change @@ -36,3 +36,7 @@ let broken = async (someAsyncFunction) => {
36
36
}
37
37
38
38
let broken = someAsyncFunction => broken (someAsyncFunction )
39
+
40
+ let nested1 = () => async (y ) => await y
41
+
42
+ let nested2 = async () => async (y ) => await y
Original file line number Diff line number Diff line change @@ -283499,6 +283499,8 @@ let rec cut n l =
283499
283499
283500
283500
let try_ids = Hashtbl.create 8
283501
283501
283502
+ let has_async_attribute exp = exp.exp_attributes |> List.exists (fun ({txt}, _payload) -> txt = "res.async")
283503
+
283502
283504
let rec transl_exp e =
283503
283505
List.iter (Translattribute.check_attribute e) e.exp_attributes;
283504
283506
transl_exp0 e
@@ -283513,7 +283515,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda =
283513
283515
| Texp_let (rec_flag, pat_expr_list, body) ->
283514
283516
transl_let rec_flag pat_expr_list (transl_exp body)
283515
283517
| Texp_function { arg_label = _; param; cases; partial } ->
283516
- let async = e.exp_attributes |> List.exists (fun ({txt}, _payload) -> txt = "res.async") in
283518
+ let async = has_async_attribute e in
283517
283519
let params, body, return_unit =
283518
283520
let pl = push_defaults e.exp_loc [] cases partial in
283519
283521
transl_function e.exp_loc partial param pl
@@ -283839,7 +283841,7 @@ and transl_function loc partial param cases =
283839
283841
} as exp;
283840
283842
};
283841
283843
]
283842
- when Parmatch.inactive ~partial pat ->
283844
+ when Parmatch.inactive ~partial pat && not (exp |> has_async_attribute) ->
283843
283845
let params, body, return_unit =
283844
283846
transl_function exp.exp_loc partial' param' cases
283845
283847
in
Original file line number Diff line number Diff line change @@ -293507,6 +293507,8 @@ let rec cut n l =
293507
293507
293508
293508
let try_ids = Hashtbl.create 8
293509
293509
293510
+ let has_async_attribute exp = exp.exp_attributes |> List.exists (fun ({txt}, _payload) -> txt = "res.async")
293511
+
293510
293512
let rec transl_exp e =
293511
293513
List.iter (Translattribute.check_attribute e) e.exp_attributes;
293512
293514
transl_exp0 e
@@ -293521,7 +293523,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda =
293521
293523
| Texp_let (rec_flag, pat_expr_list, body) ->
293522
293524
transl_let rec_flag pat_expr_list (transl_exp body)
293523
293525
| Texp_function { arg_label = _; param; cases; partial } ->
293524
- let async = e.exp_attributes |> List.exists (fun ({txt}, _payload) -> txt = "res.async") in
293526
+ let async = has_async_attribute e in
293525
293527
let params, body, return_unit =
293526
293528
let pl = push_defaults e.exp_loc [] cases partial in
293527
293529
transl_function e.exp_loc partial param pl
@@ -293847,7 +293849,7 @@ and transl_function loc partial param cases =
293847
293849
} as exp;
293848
293850
};
293849
293851
]
293850
- when Parmatch.inactive ~partial pat ->
293852
+ when Parmatch.inactive ~partial pat && not (exp |> has_async_attribute) ->
293851
293853
let params, body, return_unit =
293852
293854
transl_function exp.exp_loc partial' param' cases
293853
293855
in
Original file line number Diff line number Diff line change @@ -292966,6 +292966,8 @@ let rec cut n l =
292966
292966
292967
292967
let try_ids = Hashtbl.create 8
292968
292968
292969
+ let has_async_attribute exp = exp.exp_attributes |> List.exists (fun ({txt}, _payload) -> txt = "res.async")
292970
+
292969
292971
let rec transl_exp e =
292970
292972
List.iter (Translattribute.check_attribute e) e.exp_attributes;
292971
292973
transl_exp0 e
@@ -292980,7 +292982,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda =
292980
292982
| Texp_let (rec_flag, pat_expr_list, body) ->
292981
292983
transl_let rec_flag pat_expr_list (transl_exp body)
292982
292984
| Texp_function { arg_label = _; param; cases; partial } ->
292983
- let async = e.exp_attributes |> List.exists (fun ({txt}, _payload) -> txt = "res.async") in
292985
+ let async = has_async_attribute e in
292984
292986
let params, body, return_unit =
292985
292987
let pl = push_defaults e.exp_loc [] cases partial in
292986
292988
transl_function e.exp_loc partial param pl
@@ -293306,7 +293308,7 @@ and transl_function loc partial param cases =
293306
293308
} as exp;
293307
293309
};
293308
293310
]
293309
- when Parmatch.inactive ~partial pat ->
293311
+ when Parmatch.inactive ~partial pat && not (exp |> has_async_attribute) ->
293310
293312
let params, body, return_unit =
293311
293313
transl_function exp.exp_loc partial' param' cases
293312
293314
in
You can’t perform that action at this time.
0 commit comments