File tree 4 files changed +25
-3
lines changed
4 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ These are only breaking changes for unformatted code.
64
64
- GenType: fix issue with V3 compatibility mode (see https://github.com/rescript-lang/rescript-compiler/issues/5990 ) https://github.com/rescript-lang/rescript-compiler/pull/5991
65
65
- Fix issue in ` Js.Promise2 ` where ` then ` and ` catch ` were returning ` undefined ` https://github.com/rescript-lang/rescript-compiler/pull/5997
66
66
- Fix formatting of props spread for multiline JSX expression https://github.com/rescript-lang/rescript-compiler/pull/6006
67
+ - 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
67
68
68
69
#### :nail_care : Polish
69
70
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 ;
@@ -72,6 +73,12 @@ async function nested2(param) {
72
73
} ;
73
74
}
74
75
76
+ function onSubmit ( param ) {
77
+ return React . useCallback ( async function ( _a , b ) {
78
+ return await b ;
79
+ } ) ;
80
+ }
81
+
75
82
var tci = 3 ;
76
83
77
84
exports . willBeInlined = willBeInlined ;
@@ -90,4 +97,5 @@ exports.tui = tui;
90
97
exports . tuia = tuia ;
91
98
exports . nested1 = nested1 ;
92
99
exports . nested2 = nested2 ;
100
+ exports . onSubmit = onSubmit ;
93
101
/* inlined Not a pure module */
Original file line number Diff line number Diff line change @@ -50,3 +50,13 @@ let tuia = uncurriedIdAsync(. 3)
50
50
let nested1 = () => async (y ) => await y
51
51
52
52
let nested2 = async () => async (y ) => await y
53
+
54
+ type callback <'input , 'output > = 'input => 'output
55
+
56
+ @module ("react" )
57
+ external useCallback : (@uncurry ('input => 'output )) => callback <'input , 'output > = "useCallback"
58
+
59
+ let onSubmit = () =>
60
+ useCallback (async (_a , b ) => {
61
+ await b
62
+ })
You can’t perform that action at this time.
0 commit comments