Skip to content

Commit 4d53751

Browse files
authored
Add missing case for Ltyp_poly in Pprintast (#2240)
* add failing tests * add fix * remove the use of wildcard
1 parent 77a13f2 commit 4d53751

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

ocaml/parsing/pprintast.ml

+15-2
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,19 @@ and core_type_jane_syntax ctxt attrs f (x : Jane_syntax.Core_type.t) =
453453
(core_type1 ctxt) aliased_type
454454
tyvar_option name
455455
jkind_annotation jkind
456-
| _ -> pp f "@[<2>%a@]" (core_type1_jane_syntax ctxt attrs) x
456+
| Jtyp_layout (Ltyp_poly {bound_vars = []; inner_type}) ->
457+
core_type ctxt f inner_type
458+
| Jtyp_layout (Ltyp_poly {bound_vars; inner_type}) ->
459+
let jkind_poly_var f (name, jkind_opt) =
460+
match jkind_opt with
461+
| Some jkind -> pp f "(%a@;:@;%a)" tyvar_loc name jkind_annotation jkind
462+
| None -> tyvar_loc f name
463+
in
464+
pp f "@[<2>%a@;.@;%a@]"
465+
(list jkind_poly_var ~sep:"@;") bound_vars
466+
(core_type ctxt) inner_type
467+
| Jtyp_tuple _ | Jtyp_layout (Ltyp_var _) ->
468+
pp f "@[<2>%a@]" (core_type1_jane_syntax ctxt attrs) x
457469

458470

459471
and core_type1_jane_syntax ctxt attrs f (x : Jane_syntax.Core_type.t) =
@@ -463,7 +475,8 @@ and core_type1_jane_syntax ctxt attrs f (x : Jane_syntax.Core_type.t) =
463475
| Jtyp_layout (Ltyp_var { name; jkind }) ->
464476
pp f "(%a@;:@;%a)" tyvar_option name jkind_annotation jkind
465477
| Jtyp_tuple x -> core_type1_labeled_tuple ctxt attrs f x
466-
| _ -> paren true (core_type_jane_syntax ctxt attrs) f x
478+
| Jtyp_layout (Ltyp_alias _ | Ltyp_poly _) ->
479+
paren true (core_type_jane_syntax ctxt attrs) f x
467480

468481
and tyvar_option f = function
469482
| None -> pp f "_"

ocaml/testsuite/tests/parsetree/source_jane_street.ml

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ module type S_for_layouts = sig
2727
type t : float64
2828

2929
type variant = A : ('a : immediate). 'a -> variant
30+
31+
val f1: ('a : float64) ('b : immediate) 'c . 'a -> 'b -> 'c
32+
val f2: ('a : float64) 'b ('c : bits64) . 'a -> 'b -> 'c
33+
val f3: 'a 'b ('c : word) . 'a -> 'b -> 'c
3034
end;;
3135

3236
type ('a : immediate) for_layouts = 'a;;

0 commit comments

Comments
 (0)