Skip to content

Commit

Permalink
Fix issue with ppx and await.
Browse files Browse the repository at this point in the history
Fix issue where attributes on an application were not preserved by the AST conversion for ppx.

Fixes #7261
  • Loading branch information
cristianoc committed Jan 30, 2025
1 parent e3f28e2 commit f3c4ce2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Editor: Fix issue where completions would not show up inside of object bodies. https://github.com/rescript-lang/rescript/pull/7230
- Fix issue with pattern matching empty list which interferes with boolean optimisations. https://github.com/rescript-lang/rescript/pull/7237
- Fix Cannot combine @react.component and @directive. https://github.com/rescript-lang/rescript/pull/7260
- Fix issue where attributes on an application were not preserved by the AST conversion for ppx. https://github.com/rescript-lang/rescript/pull/????

#### :house: Internal

Expand Down
2 changes: 1 addition & 1 deletion compiler/ml/ast_mapper_to0.ml
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ module E = struct
in
let attrs =
if partial then (Location.mknoloc "res.partial", Pt.PStr []) :: attrs
else []
else attrs
in
apply ~loc ~attrs (sub.expr sub e)
(List.map (map_snd (sub.expr sub)) args)
Expand Down
7 changes: 5 additions & 2 deletions tests/tools_tests/ppx/TestPpx.res
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ module Uncurried = {

let async_succ = async x => x + 1
let async_foo = async (x, y) => {
let a: promise<int> = async_succ(x)
let b: promise<int> = async_succ(y)
let a = async_succ(x)
let b = async_succ(y)
(await a) + (await b)
}

Expand All @@ -58,3 +58,6 @@ let neq2 = 3 !== 3

let eq = 3 == 3
let eq2 = 3 === 3

let test = async () => 12
let f = async () => (await test()) + 1
10 changes: 10 additions & 0 deletions tests/tools_tests/src/expected/TestPpx.res.jsout
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ let Pipe = {

let concat = "ab";

async function test() {
return 12;
}

async function f() {
return await test() + 1 | 0;
}

let a = "A";

let b = "B";
Expand Down Expand Up @@ -104,4 +112,6 @@ exports.neq = neq;
exports.neq2 = neq2;
exports.eq = eq;
exports.eq2 = eq2;
exports.test = test;
exports.f = f;
/* Not a pure module */

0 comments on commit f3c4ce2

Please sign in to comment.