-
Notifications
You must be signed in to change notification settings - Fork 463
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
Another case of inlining breaking async #5789
Comments
External is not needed. Even easier repro: Broken.resi: let broken: (unit => promise<'a>) => promise<'a> Broken.resi: let doSomethingAsync = async someAsyncFunction => {
await someAsyncFunction()
}
let broken = someAsyncFunction => doSomethingAsync(someAsyncFunction) |
Not sure I understand either of the two examples. Why are there interface files. And if there are how many files are needed to repro. |
There is an interface file because otherwise both functions will be exported and the inlining does not happen. Actually a single file is enough to reproduce if we use %%private(
let doSomethingAsync = async someAsyncFunction => {
await someAsyncFunction()
}
)
let broken = someAsyncFunction => doSomethingAsync(someAsyncFunction) results in function broken(someAsyncFunction) {
return await Curry._1(someAsyncFunction, undefined);
} |
OK without using private, one can just do the same with a module, or shadowing: 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) |
I'll go with the latter, and notice that this prevents inlining: let broken = async (someAsyncFunction) => {
await someAsyncFunction()
}
let _ = Js.log(broken)
let broken = someAsyncFunction => broken(someAsyncFunction) |
@cristianoc Yes! It works! 🎉 Let's merge and do an rc.5. |
I'll merge and apply to master too. |
* Prevent inlining of async functions in last stage of the compiler * Update CHANGELOG.md Fixes #5789
Broken.resi:
Broken.res:
JS output does not compile because function has no
async
:/cc @cristianoc
The text was updated successfully, but these errors were encountered: