Skip to content

Commit

Permalink
Fix inline record printing in outcome printer
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro committed Mar 31, 2019
1 parent 6cf1a7a commit d7f9dbd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions formatTest/oprintTests/expected_output/inlineRecord.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type t0 = T0 { t0: int, };
type t1 = A { x: int, } | B | C { c1: string, c2: string, };
type t2(_) =
D { x: int, }: t2(int)
| E { f: int => int, }: t2(int => int)
| F(unit): t2(unit);
11 changes: 11 additions & 0 deletions formatTest/oprintTests/input/inlineRecord.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type t0 = T0 { t0 : int };
type t1 =
| A { x : int }
| B
| C { c1 : string, c2 : string };

/* GADT */
type t2(_) =
| D { x : int } : t2(int)
| E { f : int => int } : t2(int => int)
| F(unit) : t2(unit);
7 changes: 7 additions & 0 deletions src/reason-parser/reason_oprint.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,9 @@ and print_out_constr ppf (name, tyl,ret_type_opt) =
begin match tyl with
| [] ->
pp_print_string ppf name
| [Otyp_record lbls] ->
fprintf ppf "@[<2>%s {%a@;<1 -2>}@]" name
(print_list_init print_out_label (fun ppf -> fprintf ppf "@ ")) lbls
| _ ->
fprintf ppf "@[<2>%s(%a)@]" name
(print_typlist print_simple_out_type ",") tyl
Expand All @@ -813,6 +816,10 @@ and print_out_constr ppf (name, tyl,ret_type_opt) =
begin match tyl with
| [] ->
fprintf ppf "@[<2>%s:@ %a@]" name print_simple_out_type ret_type
| [Otyp_record lbls] ->
fprintf ppf "@[<2>%s {%a@;<1 -2>}: %a@]" name
(print_list_init print_out_label (fun ppf -> fprintf ppf "@ ")) lbls
print_simple_out_type ret_type
| _ ->
fprintf ppf "@[<2>%s(%a): %a@]" name
(print_typlist print_simple_out_type ",") tyl
Expand Down

0 comments on commit d7f9dbd

Please sign in to comment.