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 bb663bd
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/7262

#### :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 */

1 comment on commit bb663bd

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Syntax Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: bb663bd Previous: e1b7fb7 Ratio
Parse RedBlackTree.res - time/run 1.3637760933333332 ms 1.2123143266666667 ms 1.12
Parse Napkinscript.res - time/run 42.21984695333333 ms 39.28006235333333 ms 1.07
Parse HeroGraphic.res - time/run 6.384929913333333 ms 5.13472718 ms 1.24

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.