Skip to content

Fix issue with ppx and await. #7262

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
Jan 30, 2025
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
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 */
Loading