File tree Expand file tree Collapse file tree 8 files changed +52
-12
lines changed Expand file tree Collapse file tree 8 files changed +52
-12
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,12 @@ These are only breaking changes for unformatted code.
57
57
- Process ` @set ` annotation for field update as generating an uncurried function https://github.com/rescript-lang/rescript-compiler/pull/5846
58
58
- Treat uncurried application of primitives like curried application, which produces better output https://github.com/rescript-lang/rescript-compiler/pull/5851
59
59
60
+ # 10.1.1
61
+
62
+ #### :bug : Bug Fix
63
+
64
+ - Prevent inlining of async functions in additional cases https://github.com/rescript-lang/rescript-compiler/issues/5860
65
+
60
66
# 10.1.0
61
67
62
68
#### :bug : Bug Fix
Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ let subst (export_set : Set_ident.t) stats =
200
200
Call
201
201
( {
202
202
expression_desc =
203
- Fun {is_method= false ; params; body; env};
203
+ Fun {is_method= false ; params; body; env; async = false };
204
204
},
205
205
args,
206
206
_info );
Original file line number Diff line number Diff line change @@ -171,7 +171,10 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
171
171
ap_info;
172
172
} -> (
173
173
match Lam_compile_env. query_external_id_info ident fld_name with
174
- | { persistent_closed_lambda = Some (Lfunction { params; body; _ }) }
174
+ | {
175
+ persistent_closed_lambda =
176
+ Some (Lfunction ({ params; body } as lfunction));
177
+ }
175
178
(* be more cautious when do cross module inlining *)
176
179
when Ext_list. same_length params args
177
180
&& Ext_list. for_all args (fun arg ->
@@ -180,7 +183,8 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
180
183
match Hash_ident. find_opt meta.ident_tbl p with
181
184
| Some v -> v <> Parameter
182
185
| None -> true )
183
- | _ -> true ) ->
186
+ | _ -> true )
187
+ && Lam_analysis. lfunction_can_be_beta_reduced lfunction ->
184
188
simpl (Lam_beta_reduce. propagate_beta_reduce meta params body args)
185
189
| _ -> Lam. apply (simpl l1) (Ext_list. map args simpl) ap_info)
186
190
(* Function inlining interact with other optimizations...
Original file line number Diff line number Diff line change @@ -15,6 +15,13 @@ function wrapSomethingAsync(param) {
15
15
} ) ( 777 ) ) ;
16
16
}
17
17
18
+ function wrapSomethingAsync2 ( param ) {
19
+ ( ( async function ( param ) {
20
+ var test = await Promise . resolve ( "Test" ) ;
21
+ console . log ( test ) ;
22
+ } ) ( undefined ) ) ;
23
+ }
24
+
18
25
async function doSomethingAsync ( someAsyncFunction ) {
19
26
return await Curry . _1 ( someAsyncFunction , undefined ) ;
20
27
}
@@ -58,6 +65,7 @@ var tci = 3;
58
65
exports . willBeInlined = willBeInlined ;
59
66
exports . inlined = inlined ;
60
67
exports . wrapSomethingAsync = wrapSomethingAsync ;
68
+ exports . wrapSomethingAsync2 = wrapSomethingAsync2 ;
61
69
exports . M = M ;
62
70
exports . broken = broken$2 ;
63
71
exports . curriedId = curriedId ;
Original file line number Diff line number Diff line change @@ -11,6 +11,16 @@ let wrapSomethingAsync: unit => unit = () => {
11
11
)(777 )
12
12
}
13
13
14
+ external ignorePromise : promise <'a > => unit = "%identity"
15
+
16
+ let wrapSomethingAsync2 = () =>
17
+ (
18
+ async () => {
19
+ let test = await Js .Promise .resolve ("Test" )
20
+ Js .log (test )
21
+ }
22
+ )()-> ignorePromise
23
+
14
24
module M : {
15
25
let broken : (unit => promise <'a >) => promise <'a >
16
26
} = {
Original file line number Diff line number Diff line change @@ -92837,7 +92837,7 @@ let subst (export_set : Set_ident.t) stats =
92837
92837
Call
92838
92838
( {
92839
92839
expression_desc =
92840
- Fun {is_method=false; params; body; env};
92840
+ Fun {is_method=false; params; body; env; async=false };
92841
92841
},
92842
92842
args,
92843
92843
_info );
@@ -139496,7 +139496,10 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
139496
139496
ap_info;
139497
139497
} -> (
139498
139498
match Lam_compile_env.query_external_id_info ident fld_name with
139499
- | { persistent_closed_lambda = Some (Lfunction { params; body; _ }) }
139499
+ | {
139500
+ persistent_closed_lambda =
139501
+ Some (Lfunction ({ params; body } as lfunction));
139502
+ }
139500
139503
(* be more cautious when do cross module inlining *)
139501
139504
when Ext_list.same_length params args
139502
139505
&& Ext_list.for_all args (fun arg ->
@@ -139505,7 +139508,8 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
139505
139508
match Hash_ident.find_opt meta.ident_tbl p with
139506
139509
| Some v -> v <> Parameter
139507
139510
| None -> true)
139508
- | _ -> true) ->
139511
+ | _ -> true)
139512
+ && Lam_analysis.lfunction_can_be_beta_reduced lfunction ->
139509
139513
simpl (Lam_beta_reduce.propagate_beta_reduce meta params body args)
139510
139514
| _ -> Lam.apply (simpl l1) (Ext_list.map args simpl) ap_info)
139511
139515
(* Function inlining interact with other optimizations...
Original file line number Diff line number Diff line change @@ -92837,7 +92837,7 @@ let subst (export_set : Set_ident.t) stats =
92837
92837
Call
92838
92838
( {
92839
92839
expression_desc =
92840
- Fun {is_method=false; params; body; env};
92840
+ Fun {is_method=false; params; body; env; async=false };
92841
92841
},
92842
92842
args,
92843
92843
_info );
@@ -139496,7 +139496,10 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
139496
139496
ap_info;
139497
139497
} -> (
139498
139498
match Lam_compile_env.query_external_id_info ident fld_name with
139499
- | { persistent_closed_lambda = Some (Lfunction { params; body; _ }) }
139499
+ | {
139500
+ persistent_closed_lambda =
139501
+ Some (Lfunction ({ params; body } as lfunction));
139502
+ }
139500
139503
(* be more cautious when do cross module inlining *)
139501
139504
when Ext_list.same_length params args
139502
139505
&& Ext_list.for_all args (fun arg ->
@@ -139505,7 +139508,8 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
139505
139508
match Hash_ident.find_opt meta.ident_tbl p with
139506
139509
| Some v -> v <> Parameter
139507
139510
| None -> true)
139508
- | _ -> true) ->
139511
+ | _ -> true)
139512
+ && Lam_analysis.lfunction_can_be_beta_reduced lfunction ->
139509
139513
simpl (Lam_beta_reduce.propagate_beta_reduce meta params body args)
139510
139514
| _ -> Lam.apply (simpl l1) (Ext_list.map args simpl) ap_info)
139511
139515
(* Function inlining interact with other optimizations...
Original file line number Diff line number Diff line change @@ -141231,7 +141231,7 @@ let subst (export_set : Set_ident.t) stats =
141231
141231
Call
141232
141232
( {
141233
141233
expression_desc =
141234
- Fun {is_method=false; params; body; env};
141234
+ Fun {is_method=false; params; body; env; async=false };
141235
141235
},
141236
141236
args,
141237
141237
_info );
@@ -154666,7 +154666,10 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
154666
154666
ap_info;
154667
154667
} -> (
154668
154668
match Lam_compile_env.query_external_id_info ident fld_name with
154669
- | { persistent_closed_lambda = Some (Lfunction { params; body; _ }) }
154669
+ | {
154670
+ persistent_closed_lambda =
154671
+ Some (Lfunction ({ params; body } as lfunction));
154672
+ }
154670
154673
(* be more cautious when do cross module inlining *)
154671
154674
when Ext_list.same_length params args
154672
154675
&& Ext_list.for_all args (fun arg ->
@@ -154675,7 +154678,8 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
154675
154678
match Hash_ident.find_opt meta.ident_tbl p with
154676
154679
| Some v -> v <> Parameter
154677
154680
| None -> true)
154678
- | _ -> true) ->
154681
+ | _ -> true)
154682
+ && Lam_analysis.lfunction_can_be_beta_reduced lfunction ->
154679
154683
simpl (Lam_beta_reduce.propagate_beta_reduce meta params body args)
154680
154684
| _ -> Lam.apply (simpl l1) (Ext_list.map args simpl) ap_info)
154681
154685
(* Function inlining interact with other optimizations...
You can’t perform that action at this time.
0 commit comments