Skip to content

Commit 453be37

Browse files
committedFeb 1, 2024
Fix issue with async and newtype in uncurried mode.
Fixes #6587
1 parent c9f775c commit 453be37

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed
 

‎CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
1313
# 11.1.0-rc.2 (Unreleased)
1414

15+
#### :bug: Bug Fix
16+
17+
- Fix issue with async and newtype in uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6601
18+
1519
# 11.1.0-rc.1
1620

1721
#### :rocket: New Feature

‎jscomp/ml/ast_async.ml

+12-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ let add_promise_type ?(loc = Location.none) ~async
1313

1414
let add_async_attribute ~async (body : Parsetree.expression) =
1515
if async then
16-
{
17-
body with
18-
pexp_attributes =
19-
({txt = "res.async"; loc = Location.none}, PStr [])
20-
:: body.pexp_attributes;
21-
}
16+
(
17+
match body.pexp_desc with
18+
| Pexp_construct (x, Some e) when Ast_uncurried.exprIsUncurriedFun body ->
19+
{body with pexp_desc = Pexp_construct (x, Some {e with pexp_attributes =
20+
({txt = "res.async"; loc = Location.none}, PStr []) :: e.pexp_attributes} )}
21+
| _ ->
22+
{
23+
body with
24+
pexp_attributes =
25+
({txt = "res.async"; loc = Location.none}, PStr [])
26+
:: body.pexp_attributes;
27+
})
2228
else body
2329

2430
let rec add_promise_to_result ~loc (e : Parsetree.expression) =

‎jscomp/test/async_await.js

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎jscomp/test/async_await.res

+4
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ let arr = [1, 2, 3]
1616

1717
let toplevelAwait = await topFoo()
1818
let toplevelAwait2 = arr[await topFoo()]
19+
20+
let f = async (type input, value: input) => {
21+
await Js.Promise.resolve(. 1)
22+
}

0 commit comments

Comments
 (0)
Please sign in to comment.