Skip to content

Commit

Permalink
Tweak comment
Browse files Browse the repository at this point in the history
  • Loading branch information
rtjoa committed Dec 24, 2024
1 parent eb42fd2 commit 099d3b5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions typing/typedecl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 099d3b5

Please sign in to comment.