Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Fix issue with printing async functions with locally abstract types #732

Merged
merged 1 commit into from
Feb 6, 2023
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 @@ -58,6 +58,7 @@
- Fix an issue where error messages related to duplicate props were displayed without a loc and were unclear https://github.com/rescript-lang/syntax/pull/728
- Fix issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/syntax/pull/730
- Fix issue where uncurried functions were incorrectly converting the type of a prop given as a default value to curried https://github.com/rescript-lang/syntax/pull/731
- Fix issue with printing async functions with locally abstract types https://github.com/rescript-lang/syntax/pull/732

#### :eyeglasses: Spec Compliance

Expand Down
6 changes: 2 additions & 4 deletions src/res_parsetree_viewer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,8 @@ let funExpr expr =
| expr -> (attrsBefore, List.rev acc, expr)
in
match expr with
| {
pexp_desc = Pexp_fun (_, _defaultExpr, _pattern, _returnExpr);
pexp_attributes = attrs;
} as expr ->
| {pexp_desc = Pexp_fun _ | Pexp_newtype _; pexp_attributes = attrs} as expr
->
collect attrs [] {expr with pexp_attributes = []}
| expr -> collect [] [] expr

Expand Down
7 changes: 6 additions & 1 deletion tests/printer/expr/asyncAwait.res
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,9 @@ let b4 = await (foo.bar.baz)

let c1 = @foo x => @bar y => x + y
let c2 = (. x) => y => x+y
let c3 = (. x) => @foo y => x+y
let c3 = (. x) => @foo y => x+y

let f = async (type a, ()) => {
await Js.Promise.resolve(())
}

4 changes: 4 additions & 0 deletions tests/printer/expr/expected/asyncAwait.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,7 @@ let b4 = await foo.bar.baz
let c1 = @foo x => @bar y => x + y
let c2 = (. x, y) => x + y
let c3 = (. x) => @foo y => x + y

let f = async (type a, ()) => {
await Js.Promise.resolve()
}
18 changes: 6 additions & 12 deletions tests/printer/expr/expected/newtype.res.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
let f = (type t, xs: list<t>) => ()
let f = (@attr type t, xs: list<t>) => ()
let f = @attr (type t, xs: list<t>) => ()
let f = (type t, xs: list<t>, type s, ys: list<s>) => ()
let f = (@attr type t, xs: list<t>, @attr2 type s, ys: list<s>) => ()
let f = @attr (type t, xs: list<t>, @attr2 type s, ys: list<s>) => ()
let f = (type t u v, xs: list<(t, u, v)>) => ()
let f = (@attr type t u v, xs: list<(t, u, v)>) => ()
let f = @attr (type t u v, xs: list<(t, u, v)>) => ()
let f = (type t u v, xs: list<(t, u, v)>, type s w z, ys: list<(s, w, z)>) => ()
let f = (@attr type t u v, xs: list<(t, u, v)>, @attr2 type s w z, ys: list<(s, w, z)>) => ()
let f = (
@attr type t,
@attr type s,
xs: list<(t, s)>,
@attr type u,
@attr type v w,
ys: list<(u, v, w)>,
) => ()
let f = @attr (type t u v, xs: list<(t, u, v)>, @attr2 type s w z, ys: list<(s, w, z)>) => ()
let f = @attr
(type t, @attr type s, xs: list<(t, s)>, @attr type u, @attr type v w, ys: list<(u, v, w)>) => ()

let mk_formatting_gen:
type a b c d e f. formatting_gen<a, b, c, d, e, f> => Parsetree.expression =
Expand Down