Skip to content

Commit 85b5c54

Browse files
authored
flambda-backend: Small improvement to layout inference for mutually recursive type decl parameters (#1766)
Small improvement to layout inference
1 parent 0c57382 commit 85b5c54

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

testsuite/tests/typing-layouts/datatypes_alpha.ml

+7
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,10 @@ and t2 = Mk1 of t_void t | Mk2
327327
type ('b : void) t = 'b void_t * t2
328328
and t2 = Mk1 of t_void t | Mk2
329329
|}]
330+
331+
type 'a t8_5 = { x : 'a t8_6; y : string}
332+
and 'a t8_6 = 'a void_t;;
333+
[%%expect {|
334+
type ('a : void) t8_5 = { x : 'a t8_6; y : string; }
335+
and ('a : void) t8_6 = 'a void_t
336+
|}]

typing/typedecl.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1499,6 +1499,8 @@ let transl_type_decl env rec_flag sdecl_list =
14991499
raise (Error (loc, Type_clash (new_env, err))))
15001500
checks)
15011501
delayed_layout_checks;
1502+
(* Check that constraints are enforced *)
1503+
List.iter2 (check_constraints new_env) sdecl_list decls;
15021504
(* Check that all type variables are closed; this also defaults any remaining
15031505
sort variables. Defaulting must happen before update_decls_layout,
15041506
Typedecl_seperability.update_decls, and add_types_to_env, all of which need
@@ -1512,8 +1514,6 @@ let transl_type_decl env rec_flag sdecl_list =
15121514
Some ty -> raise(Error(sdecl.ptype_loc, Unbound_type_var(ty,decl)))
15131515
| None -> ())
15141516
sdecl_list tdecls;
1515-
(* Check that constraints are enforced *)
1516-
List.iter2 (check_constraints new_env) sdecl_list decls;
15171517
(* Add type properties to declarations *)
15181518
let decls =
15191519
try

0 commit comments

Comments
 (0)