Skip to content

Commit f3c4ce2

Browse files
committed
Fix issue with ppx and await.
Fix issue where attributes on an application were not preserved by the AST conversion for ppx. Fixes #7261
1 parent e3f28e2 commit f3c4ce2

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Editor: Fix issue where completions would not show up inside of object bodies. https://github.com/rescript-lang/rescript/pull/7230
2020
- Fix issue with pattern matching empty list which interferes with boolean optimisations. https://github.com/rescript-lang/rescript/pull/7237
2121
- Fix Cannot combine @react.component and @directive. https://github.com/rescript-lang/rescript/pull/7260
22+
- Fix issue where attributes on an application were not preserved by the AST conversion for ppx. https://github.com/rescript-lang/rescript/pull/????
2223

2324
#### :house: Internal
2425

compiler/ml/ast_mapper_to0.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ module E = struct
346346
in
347347
let attrs =
348348
if partial then (Location.mknoloc "res.partial", Pt.PStr []) :: attrs
349-
else []
349+
else attrs
350350
in
351351
apply ~loc ~attrs (sub.expr sub e)
352352
(List.map (map_snd (sub.expr sub)) args)

tests/tools_tests/ppx/TestPpx.res

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ module Uncurried = {
3838

3939
let async_succ = async x => x + 1
4040
let async_foo = async (x, y) => {
41-
let a: promise<int> = async_succ(x)
42-
let b: promise<int> = async_succ(y)
41+
let a = async_succ(x)
42+
let b = async_succ(y)
4343
(await a) + (await b)
4444
}
4545

@@ -58,3 +58,6 @@ let neq2 = 3 !== 3
5858

5959
let eq = 3 == 3
6060
let eq2 = 3 === 3
61+
62+
let test = async () => 12
63+
let f = async () => (await test()) + 1

tests/tools_tests/src/expected/TestPpx.res.jsout

+10
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ let Pipe = {
7272

7373
let concat = "ab";
7474

75+
async function test() {
76+
return 12;
77+
}
78+
79+
async function f() {
80+
return await test() + 1 | 0;
81+
}
82+
7583
let a = "A";
7684

7785
let b = "B";
@@ -104,4 +112,6 @@ exports.neq = neq;
104112
exports.neq2 = neq2;
105113
exports.eq = eq;
106114
exports.eq2 = eq2;
115+
exports.test = test;
116+
exports.f = f;
107117
/* Not a pure module */

0 commit comments

Comments
 (0)