Skip to content

Small improvement to layout inference for mutually recursive type decl parameters #1766

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ocaml/testsuite/tests/typing-layouts/datatypes_alpha.ml
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,10 @@ and t2 = Mk1 of t_void t | Mk2
type ('b : void) t = 'b void_t * t2
and t2 = Mk1 of t_void t | Mk2
|}]

type 'a t8_5 = { x : 'a t8_6; y : string}
and 'a t8_6 = 'a void_t;;
[%%expect {|
type ('a : void) t8_5 = { x : 'a t8_6; y : string; }
and ('a : void) t8_6 = 'a void_t
|}]
4 changes: 2 additions & 2 deletions ocaml/typing/typedecl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,8 @@ let transl_type_decl env rec_flag sdecl_list =
raise (Error (loc, Type_clash (new_env, err))))
checks)
delayed_layout_checks;
(* Check that constraints are enforced *)
List.iter2 (check_constraints new_env) sdecl_list decls;
(* Check that all type variables are closed; this also defaults any remaining
sort variables. Defaulting must happen before update_decls_layout,
Typedecl_seperability.update_decls, and add_types_to_env, all of which need
Expand All @@ -1512,8 +1514,6 @@ let transl_type_decl env rec_flag sdecl_list =
Some ty -> raise(Error(sdecl.ptype_loc, Unbound_type_var(ty,decl)))
| None -> ())
sdecl_list tdecls;
(* Check that constraints are enforced *)
List.iter2 (check_constraints new_env) sdecl_list decls;
(* Add type properties to declarations *)
let decls =
try
Expand Down