Skip to content

Fix issue with async and newtype in uncurried mode. #6601

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

Merged
merged 1 commit into from
Feb 1, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

# 11.1.0-rc.2 (Unreleased)

#### :bug: Bug Fix

- Fix issue with async and newtype in uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6601

# 11.1.0-rc.1

#### :rocket: New Feature
Expand Down
18 changes: 12 additions & 6 deletions jscomp/ml/ast_async.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ let add_promise_type ?(loc = Location.none) ~async

let add_async_attribute ~async (body : Parsetree.expression) =
if async then
{
body with
pexp_attributes =
({txt = "res.async"; loc = Location.none}, PStr [])
:: body.pexp_attributes;
}
(
match body.pexp_desc with
| Pexp_construct (x, Some e) when Ast_uncurried.exprIsUncurriedFun body ->
{body with pexp_desc = Pexp_construct (x, Some {e with pexp_attributes =
({txt = "res.async"; loc = Location.none}, PStr []) :: e.pexp_attributes} )}
| _ ->
{
body with
pexp_attributes =
({txt = "res.async"; loc = Location.none}, PStr [])
:: body.pexp_attributes;
})
else body

let rec add_promise_to_result ~loc (e : Parsetree.expression) =
Expand Down
5 changes: 5 additions & 0 deletions jscomp/test/async_await.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions jscomp/test/async_await.res
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ let arr = [1, 2, 3]

let toplevelAwait = await topFoo()
let toplevelAwait2 = arr[await topFoo()]

let f = async (type input, value: input) => {
await Js.Promise.resolve(. 1)
}