From 099d3b587549225399bc88f39363db1b790fc0b0 Mon Sep 17 00:00:00 2001 From: Ryan Tjoa Date: Tue, 24 Dec 2024 12:15:50 -0500 Subject: [PATCH] Tweak comment --- typing/typedecl.ml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/typing/typedecl.ml b/typing/typedecl.ml index d41ac9a7d75..4f8d02cf356 100644 --- a/typing/typedecl.ml +++ b/typing/typedecl.ml @@ -1948,15 +1948,17 @@ let update_decls_jkind env decls = - if -rectypes is not used, we only allow cycles in the type graph if they go through an object or polymorphic variant type *) -(* We only allow recursion of unboxed product types through boxing, otherwise - the type is uninhabitable and usually also infinite-size. +(* We only allow recursion in unboxed product types to occur through boxes, + otherwise the type is uninhabitable and usually also infinite-size. + See [typing-layouts-unboxed-records/recursive.ml]. - Because `check_well_founded` already ruled out recursion without through - structural types (unboxed tuples and aliases), we just look for a cycle in - paths. + Because `check_well_founded` already ruled out recursion through structural + types (for this check, we care about unboxed tuples and aliases), we just + look for a cycle in nominal unboxed types ([@@unboxed] types and unboxed + records), tracking the set of seen paths. An alternative implementation could have introduced layout variables (for - this check only), and find infinite-size types via the occurs check. Such an + this check only), finding infinite-size types via the occurs check. Such an implementation might be more principled, accepting finite-size recursive types like [type t = #{ t : t }]. The current implementation gives more informative error traces, and leaves the flexiblity to switch to a less