Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async inline 2 #5790

Merged
merged 2 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
> - :house: [Internal]
> - :nail_care: [Polish]

# 10.1.0-rc.5

#### :bug: Bug Fix

- 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

# 10.1.0-rc.4

#### :rocket: New Feature
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/js_pass_tailcall_inline.ml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ let subst (export_set : Set_ident.t) stats =
Some
{
expression_desc =
Fun {is_method=false; params; body; env};
Fun {is_method=false; params; body; env; async=false};
comment = _;
};
(*TODO: don't inline method tail call yet,
Expand Down
19 changes: 19 additions & 0 deletions jscomp/test/async_inline.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

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

async function willBeInlined(param) {
return 3;
Expand All @@ -14,7 +15,25 @@ function wrapSomethingAsync(param) {
})(777));
}

async function doSomethingAsync(someAsyncFunction) {
return await Curry._1(someAsyncFunction, undefined);
}

var broken = doSomethingAsync;

var M = {
broken: broken
};

async function broken$1(someAsyncFunction) {
return await Curry._1(someAsyncFunction, undefined);
}

var broken$2 = broken$1;

exports.willBeInlined = willBeInlined;
exports.inlined = inlined;
exports.wrapSomethingAsync = wrapSomethingAsync;
exports.M = M;
exports.broken = broken$2;
/* inlined Not a pure module */
18 changes: 17 additions & 1 deletion jscomp/test/async_inline.res
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,20 @@ let wrapSomethingAsync: unit => unit = () => {
Js.log(test)
}
)(777)
}
}

module M: {
let broken: (unit => promise<'a>) => promise<'a>
} = {
let doSomethingAsync = async (someAsyncFunction) => {
await someAsyncFunction()
}

let broken = someAsyncFunction => doSomethingAsync(someAsyncFunction)
}

let broken = async (someAsyncFunction) => {
await someAsyncFunction()
}

let broken = someAsyncFunction => broken(someAsyncFunction)
2 changes: 1 addition & 1 deletion lib/4.06.1/unstable/js_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -92734,7 +92734,7 @@ let subst (export_set : Set_ident.t) stats =
Some
{
expression_desc =
Fun {is_method=false; params; body; env};
Fun {is_method=false; params; body; env; async=false};
comment = _;
};
(*TODO: don't inline method tail call yet,
Expand Down
2 changes: 1 addition & 1 deletion lib/4.06.1/unstable/js_playground_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -92734,7 +92734,7 @@ let subst (export_set : Set_ident.t) stats =
Some
{
expression_desc =
Fun {is_method=false; params; body; env};
Fun {is_method=false; params; body; env; async=false};
comment = _;
};
(*TODO: don't inline method tail call yet,
Expand Down
2 changes: 1 addition & 1 deletion lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -262095,7 +262095,7 @@ let subst (export_set : Set_ident.t) stats =
Some
{
expression_desc =
Fun {is_method=false; params; body; env};
Fun {is_method=false; params; body; env; async=false};
comment = _;
};
(*TODO: don't inline method tail call yet,
Expand Down