File tree 7 files changed +44
-13
lines changed
7 files changed +44
-13
lines changed Original file line number Diff line number Diff line change 27
27
- Fix issue with overlapping labelled argument with default value https://github.com/rescript-lang/syntax/pull/734
28
28
- Fix issue with using alias and default value together https://github.com/rescript-lang/syntax/pull/734
29
29
- Fix issue in ` Js.Promise2 ` where ` then ` and ` catch ` were returning ` undefined ` https://github.com/rescript-lang/rescript-compiler/pull/5996
30
+ - Fix issue in the compiler back-end where async functions passed to an ` @uncurry ` external would be inlined and transformed in a way that loses async https://github.com/rescript-lang/rescript-compiler/pull/6011
30
31
31
32
#### :rocket : New Feature
32
33
Original file line number Diff line number Diff line change @@ -113,13 +113,16 @@ let unsafe_adjust_to_arity loc ~(to_ : int) ?(from : int option) (fn : Lam.t) :
113
113
let ap_info : Lam.ap_info =
114
114
{ ap_loc = loc; ap_inlined = Default_inline ; ap_status = App_na }
115
115
in
116
+ let is_async_fn = match fn with
117
+ | Lfunction { attr = {async} } -> async
118
+ | _ -> false in
116
119
match (from, fn) with
117
120
| Some from , _ | None , Lfunction { arity = from } -> (
118
- if from = to_ then fn
121
+ if from = to_ || is_async_fn then fn
119
122
else if to_ = 0 then
120
123
match fn with
121
- | Lfunction { params = [ param ]; body; attr = {async} } ->
122
- Lam. function_ ~arity: 0 ~attr: { Lambda. default_function_attribute with async}
124
+ | Lfunction { params = [ param ]; body } ->
125
+ Lam. function_ ~arity: 0 ~attr: Lambda. default_function_attribute
123
126
~params: []
124
127
~body: (Lam. let_ Alias param Lam. unit body)
125
128
(* could be only introduced by
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
var Curry = require ( "../../lib/js/curry.js" ) ;
4
+ var React = require ( "react" ) ;
4
5
5
6
async function willBeInlined ( param ) {
6
7
return 3 ;
@@ -50,6 +51,12 @@ async function nested2(param) {
50
51
} ;
51
52
}
52
53
54
+ function onSubmit ( param ) {
55
+ return React . useCallback ( async function ( _a , b ) {
56
+ return await b ;
57
+ } ) ;
58
+ }
59
+
53
60
exports . willBeInlined = willBeInlined ;
54
61
exports . inlined = inlined ;
55
62
exports . wrapSomethingAsync = wrapSomethingAsync ;
@@ -58,4 +65,5 @@ exports.M = M;
58
65
exports . broken = broken$2 ;
59
66
exports . nested1 = nested1 ;
60
67
exports . nested2 = nested2 ;
68
+ exports . onSubmit = onSubmit ;
61
69
/* inlined Not a pure module */
Original file line number Diff line number Diff line change @@ -39,4 +39,14 @@ let broken = someAsyncFunction => broken(someAsyncFunction)
39
39
40
40
let nested1 = () => async (y ) => await y
41
41
42
- let nested2 = async () => async (y ) => await y
42
+ let nested2 = async () => async (y ) => await y
43
+
44
+ type callback <'input , 'output > = 'input => 'output
45
+
46
+ @module ("react" )
47
+ external useCallback : (@uncurry ('input => 'output )) => callback <'input , 'output > = "useCallback"
48
+
49
+ let onSubmit = () =>
50
+ useCallback (async (_a , b ) => {
51
+ await b
52
+ })
Original file line number Diff line number Diff line change @@ -98870,13 +98870,16 @@ let unsafe_adjust_to_arity loc ~(to_ : int) ?(from : int option) (fn : Lam.t) :
98870
98870
let ap_info : Lam.ap_info =
98871
98871
{ ap_loc = loc; ap_inlined = Default_inline; ap_status = App_na }
98872
98872
in
98873
+ let is_async_fn = match fn with
98874
+ | Lfunction { attr = {async}} -> async
98875
+ | _ -> false in
98873
98876
match (from, fn) with
98874
98877
| Some from, _ | None, Lfunction { arity = from } -> (
98875
- if from = to_ then fn
98878
+ if from = to_ || is_async_fn then fn
98876
98879
else if to_ = 0 then
98877
98880
match fn with
98878
- | Lfunction { params = [ param ]; body; attr = {async} } ->
98879
- Lam.function_ ~arity:0 ~attr:{ Lambda.default_function_attribute with async}
98881
+ | Lfunction { params = [ param ]; body } ->
98882
+ Lam.function_ ~arity:0 ~attr:Lambda.default_function_attribute
98880
98883
~params:[]
98881
98884
~body:(Lam.let_ Alias param Lam.unit body)
98882
98885
(* could be only introduced by
Original file line number Diff line number Diff line change @@ -98870,13 +98870,16 @@ let unsafe_adjust_to_arity loc ~(to_ : int) ?(from : int option) (fn : Lam.t) :
98870
98870
let ap_info : Lam.ap_info =
98871
98871
{ ap_loc = loc; ap_inlined = Default_inline; ap_status = App_na }
98872
98872
in
98873
+ let is_async_fn = match fn with
98874
+ | Lfunction { attr = {async}} -> async
98875
+ | _ -> false in
98873
98876
match (from, fn) with
98874
98877
| Some from, _ | None, Lfunction { arity = from } -> (
98875
- if from = to_ then fn
98878
+ if from = to_ || is_async_fn then fn
98876
98879
else if to_ = 0 then
98877
98880
match fn with
98878
- | Lfunction { params = [ param ]; body; attr = {async} } ->
98879
- Lam.function_ ~arity:0 ~attr:{ Lambda.default_function_attribute with async}
98881
+ | Lfunction { params = [ param ]; body } ->
98882
+ Lam.function_ ~arity:0 ~attr:Lambda.default_function_attribute
98880
98883
~params:[]
98881
98884
~body:(Lam.let_ Alias param Lam.unit body)
98882
98885
(* could be only introduced by
Original file line number Diff line number Diff line change @@ -268166,13 +268166,16 @@ let unsafe_adjust_to_arity loc ~(to_ : int) ?(from : int option) (fn : Lam.t) :
268166
268166
let ap_info : Lam.ap_info =
268167
268167
{ ap_loc = loc; ap_inlined = Default_inline; ap_status = App_na }
268168
268168
in
268169
+ let is_async_fn = match fn with
268170
+ | Lfunction { attr = {async}} -> async
268171
+ | _ -> false in
268169
268172
match (from, fn) with
268170
268173
| Some from, _ | None, Lfunction { arity = from } -> (
268171
- if from = to_ then fn
268174
+ if from = to_ || is_async_fn then fn
268172
268175
else if to_ = 0 then
268173
268176
match fn with
268174
- | Lfunction { params = [ param ]; body; attr = {async} } ->
268175
- Lam.function_ ~arity:0 ~attr:{ Lambda.default_function_attribute with async}
268177
+ | Lfunction { params = [ param ]; body } ->
268178
+ Lam.function_ ~arity:0 ~attr:Lambda.default_function_attribute
268176
268179
~params:[]
268177
268180
~body:(Lam.let_ Alias param Lam.unit body)
268178
268181
(* could be only introduced by
You can’t perform that action at this time.
0 commit comments