diff --git a/CHANGELOG.md b/CHANGELOG.md index ad7df0d58f..d2910607d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/jscomp/core/js_pass_tailcall_inline.ml b/jscomp/core/js_pass_tailcall_inline.ml index 18e195e854..3ae42a5081 100644 --- a/jscomp/core/js_pass_tailcall_inline.ml +++ b/jscomp/core/js_pass_tailcall_inline.ml @@ -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, diff --git a/jscomp/test/async_inline.js b/jscomp/test/async_inline.js index 80db73efcd..f9b240b196 100644 --- a/jscomp/test/async_inline.js +++ b/jscomp/test/async_inline.js @@ -1,5 +1,6 @@ 'use strict'; +var Curry = require("../../lib/js/curry.js"); async function willBeInlined(param) { return 3; @@ -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 */ diff --git a/jscomp/test/async_inline.res b/jscomp/test/async_inline.res index 7ea557bbc1..f8dd74a9a2 100644 --- a/jscomp/test/async_inline.res +++ b/jscomp/test/async_inline.res @@ -9,4 +9,20 @@ let wrapSomethingAsync: unit => unit = () => { Js.log(test) } )(777) -} \ No newline at end of file +} + +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) diff --git a/lib/4.06.1/unstable/js_compiler.ml b/lib/4.06.1/unstable/js_compiler.ml index 9636106280..6e32c4a408 100644 --- a/lib/4.06.1/unstable/js_compiler.ml +++ b/lib/4.06.1/unstable/js_compiler.ml @@ -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, diff --git a/lib/4.06.1/unstable/js_playground_compiler.ml b/lib/4.06.1/unstable/js_playground_compiler.ml index 8c7f88d1f0..2abc2f8e13 100644 --- a/lib/4.06.1/unstable/js_playground_compiler.ml +++ b/lib/4.06.1/unstable/js_playground_compiler.ml @@ -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, diff --git a/lib/4.06.1/whole_compiler.ml b/lib/4.06.1/whole_compiler.ml index e64235a10d..b27d032d90 100644 --- a/lib/4.06.1/whole_compiler.ml +++ b/lib/4.06.1/whole_compiler.ml @@ -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,