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

Commit 2ed49ea

Browse files
committed
Fix issue with printing async functions with locally abstract types
1 parent 392c100 commit 2ed49ea

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
- 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
5959
- Fix issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/syntax/pull/730
6060
- 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
61+
- Fix issue with printing async functions with locally abstract types https://github.com/rescript-lang/syntax/pull/732
6162

6263
#### :eyeglasses: Spec Compliance
6364

src/res_parsetree_viewer.ml

+2-4
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,8 @@ let funExpr expr =
163163
| expr -> (attrsBefore, List.rev acc, expr)
164164
in
165165
match expr with
166-
| {
167-
pexp_desc = Pexp_fun (_, _defaultExpr, _pattern, _returnExpr);
168-
pexp_attributes = attrs;
169-
} as expr ->
166+
| {pexp_desc = Pexp_fun _ | Pexp_newtype _; pexp_attributes = attrs} as expr
167+
->
170168
collect attrs [] {expr with pexp_attributes = []}
171169
| expr -> collect [] [] expr
172170

tests/printer/expr/asyncAwait.res

+6-1
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,9 @@ let b4 = await (foo.bar.baz)
116116

117117
let c1 = @foo x => @bar y => x + y
118118
let c2 = (. x) => y => x+y
119-
let c3 = (. x) => @foo y => x+y
119+
let c3 = (. x) => @foo y => x+y
120+
121+
let f = async (type a, ()) => {
122+
await Js.Promise.resolve(())
123+
}
124+

tests/printer/expr/expected/asyncAwait.res.txt

+4
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,7 @@ let b4 = await foo.bar.baz
139139
let c1 = @foo x => @bar y => x + y
140140
let c2 = (. x, y) => x + y
141141
let c3 = (. x) => @foo y => x + y
142+
143+
let f = async (type a, ()) => {
144+
await Js.Promise.resolve()
145+
}

tests/printer/expr/expected/newtype.res.txt

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
let f = (type t, xs: list<t>) => ()
2-
let f = (@attr type t, xs: list<t>) => ()
2+
let f = @attr (type t, xs: list<t>) => ()
33
let f = (type t, xs: list<t>, type s, ys: list<s>) => ()
4-
let f = (@attr type t, xs: list<t>, @attr2 type s, ys: list<s>) => ()
4+
let f = @attr (type t, xs: list<t>, @attr2 type s, ys: list<s>) => ()
55
let f = (type t u v, xs: list<(t, u, v)>) => ()
6-
let f = (@attr type t u v, xs: list<(t, u, v)>) => ()
6+
let f = @attr (type t u v, xs: list<(t, u, v)>) => ()
77
let f = (type t u v, xs: list<(t, u, v)>, type s w z, ys: list<(s, w, z)>) => ()
8-
let f = (@attr type t u v, xs: list<(t, u, v)>, @attr2 type s w z, ys: list<(s, w, z)>) => ()
9-
let f = (
10-
@attr type t,
11-
@attr type s,
12-
xs: list<(t, s)>,
13-
@attr type u,
14-
@attr type v w,
15-
ys: list<(u, v, w)>,
16-
) => ()
8+
let f = @attr (type t u v, xs: list<(t, u, v)>, @attr2 type s w z, ys: list<(s, w, z)>) => ()
9+
let f = @attr
10+
(type t, @attr type s, xs: list<(t, s)>, @attr type u, @attr type v w, ys: list<(u, v, w)>) => ()
1711

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

0 commit comments

Comments
 (0)