Skip to content

Commit 9f6a3c9

Browse files
authored
Correct order of printed quantified type vars (#2126)
1 parent ff1982d commit 9f6a3c9

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

ocaml/testsuite/tests/typing-layouts/annots.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ let f : (_ : immediate) -> (_ : value) = fun _ -> assert false
226226
let g : (_ : value) -> (_ : immediate) = fun _ -> assert false
227227

228228
[%%expect {|
229-
val f : 'b ('a : immediate). 'a -> 'b = <fun>
230-
val g : ('b : immediate) 'a. 'a -> 'b = <fun>
229+
val f : ('a : immediate) 'b. 'a -> 'b = <fun>
230+
val g : 'a ('b : immediate). 'a -> 'b = <fun>
231231
|}]
232232

233233
(********************************************)
@@ -551,13 +551,13 @@ val f : ('a : immediate). 'a -> 'a = <fun>
551551
let f = fun x y (type (a : immediate)) (z : a) -> z
552552

553553
[%%expect{|
554-
val f : ('a : immediate) 'c 'b. 'b -> 'c -> 'a -> 'a = <fun>
554+
val f : 'b 'c ('a : immediate). 'b -> 'c -> 'a -> 'a = <fun>
555555
|}]
556556

557557
let f = fun x y (type a : immediate) (z : a) -> z
558558

559559
[%%expect{|
560-
val f : ('a : immediate) 'c 'b. 'b -> 'c -> 'a -> 'a = <fun>
560+
val f : 'b 'c ('a : immediate). 'b -> 'c -> 'a -> 'a = <fun>
561561
|}]
562562
(* CR layouts: canonicalizing the order of quantification here
563563
would reduce wibbles in error messages *)
@@ -574,7 +574,7 @@ exception E : ('a : immediate) ('b : any). 'b t2_any * 'a list -> exn
574574

575575
[%%expect{|
576576
type (_ : any) t2_any
577-
exception E : ('a : immediate) ('b : any). 'b t2_any * 'a list -> exn
577+
exception E : ('b : any) ('a : immediate). 'b t2_any * 'a list -> exn
578578
|}]
579579

580580

ocaml/testsuite/tests/typing-layouts/basics.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ end;;
649649
module M11_3f :
650650
sig
651651
type ('a : float64) t = 'a
652-
val foo : 'b ('a : float64). < usefloat : 'a t -> 'b; .. > -> 'a t -> 'b
652+
val foo : ('a : float64) 'b. < usefloat : 'a t -> 'b; .. > -> 'a t -> 'b
653653
end
654654
|}];;
655655

@@ -1265,7 +1265,7 @@ let q () =
12651265
()
12661266

12671267
[%%expect{|
1268-
val ( let* ) : 'b ('a : float64). 'a -> 'b -> unit = <fun>
1268+
val ( let* ) : ('a : float64) 'b. 'a -> 'b -> unit = <fun>
12691269
val ( and* ) : 'a -> 'b -> t_float64 = <fun>
12701270
val q : unit -> unit = <fun>
12711271
|}]

ocaml/testsuite/tests/typing-layouts/basics_alpha.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ let q () =
14551455
()
14561456

14571457
[%%expect{|
1458-
val ( let* ) : 'b ('a : float64). 'a -> 'b -> unit = <fun>
1458+
val ( let* ) : ('a : float64) 'b. 'a -> 'b -> unit = <fun>
14591459
val ( and* ) : 'a -> 'b -> t_float64 = <fun>
14601460
val q : unit -> unit = <fun>
14611461
|}]

ocaml/typing/printtyp.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,6 +1549,10 @@ let zap_qtvs_if_boring qtvs =
15491549
This implements Case (C3) from Note [When to print jkind annotations]. *)
15501550
let extract_qtvs tyl =
15511551
let fvs = Ctype.free_non_row_variables_of_list tyl in
1552+
(* The [Ctype.free*variables] family of functions returns the free
1553+
variables in reverse order they were encountered in the list of types.
1554+
*)
1555+
let fvs = List.rev fvs in
15521556
let tfvs = List.map Transient_expr.repr fvs in
15531557
let vars_jkinds = tree_of_qtvs tfvs in
15541558
zap_qtvs_if_boring vars_jkinds

0 commit comments

Comments
 (0)