Skip to content

Commit af93631

Browse files
authoredNov 9, 2022
Async inline 2 (#5790)
* Prevent inlining of async functions in last stage of the compiler * Update CHANGELOG.md Fixes #5789
1 parent b34dbd0 commit af93631

7 files changed

+46
-5
lines changed
 

‎CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
> - :house: [Internal]
1111
> - :nail_care: [Polish]
1212
13+
# 10.1.0-rc.5
14+
15+
#### :bug: Bug Fix
16+
17+
- Prevent inlining of async functions in last stage of the compiler when the functions are not exported (not in interface file or shadowed) https://github.com/rescript-lang/rescript-compiler/pull/5790
18+
1319
# 10.1.0-rc.4
1420

1521
#### :rocket: New Feature

‎jscomp/core/js_pass_tailcall_inline.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ let subst (export_set : Set_ident.t) stats =
165165
Some
166166
{
167167
expression_desc =
168-
Fun {is_method=false; params; body; env};
168+
Fun {is_method=false; params; body; env; async=false};
169169
comment = _;
170170
};
171171
(*TODO: don't inline method tail call yet,

‎jscomp/test/async_inline.js

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

3+
var Curry = require("../../lib/js/curry.js");
34

45
async function willBeInlined(param) {
56
return 3;
@@ -14,7 +15,25 @@ function wrapSomethingAsync(param) {
1415
})(777));
1516
}
1617

18+
async function doSomethingAsync(someAsyncFunction) {
19+
return await Curry._1(someAsyncFunction, undefined);
20+
}
21+
22+
var broken = doSomethingAsync;
23+
24+
var M = {
25+
broken: broken
26+
};
27+
28+
async function broken$1(someAsyncFunction) {
29+
return await Curry._1(someAsyncFunction, undefined);
30+
}
31+
32+
var broken$2 = broken$1;
33+
1734
exports.willBeInlined = willBeInlined;
1835
exports.inlined = inlined;
1936
exports.wrapSomethingAsync = wrapSomethingAsync;
37+
exports.M = M;
38+
exports.broken = broken$2;
2039
/* inlined Not a pure module */

‎jscomp/test/async_inline.res

+17-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,20 @@ let wrapSomethingAsync: unit => unit = () => {
99
Js.log(test)
1010
}
1111
)(777)
12-
}
12+
}
13+
14+
module M: {
15+
let broken: (unit => promise<'a>) => promise<'a>
16+
} = {
17+
let doSomethingAsync = async (someAsyncFunction) => {
18+
await someAsyncFunction()
19+
}
20+
21+
let broken = someAsyncFunction => doSomethingAsync(someAsyncFunction)
22+
}
23+
24+
let broken = async (someAsyncFunction) => {
25+
await someAsyncFunction()
26+
}
27+
28+
let broken = someAsyncFunction => broken(someAsyncFunction)

‎lib/4.06.1/unstable/js_compiler.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -92734,7 +92734,7 @@ let subst (export_set : Set_ident.t) stats =
9273492734
Some
9273592735
{
9273692736
expression_desc =
92737-
Fun {is_method=false; params; body; env};
92737+
Fun {is_method=false; params; body; env; async=false};
9273892738
comment = _;
9273992739
};
9274092740
(*TODO: don't inline method tail call yet,

‎lib/4.06.1/unstable/js_playground_compiler.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -92734,7 +92734,7 @@ let subst (export_set : Set_ident.t) stats =
9273492734
Some
9273592735
{
9273692736
expression_desc =
92737-
Fun {is_method=false; params; body; env};
92737+
Fun {is_method=false; params; body; env; async=false};
9273892738
comment = _;
9273992739
};
9274092740
(*TODO: don't inline method tail call yet,

‎lib/4.06.1/whole_compiler.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -262095,7 +262095,7 @@ let subst (export_set : Set_ident.t) stats =
262095262095
Some
262096262096
{
262097262097
expression_desc =
262098-
Fun {is_method=false; params; body; env};
262098+
Fun {is_method=false; params; body; env; async=false};
262099262099
comment = _;
262100262100
};
262101262101
(*TODO: don't inline method tail call yet,

0 commit comments

Comments
 (0)