Skip to content

Commit

Permalink
Add example of conservatively rejected recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
rtjoa committed Dec 26, 2024
1 parent b7d41f8 commit c5fc9cf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions testsuite/tests/typing-layouts-unboxed-records/recursive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,20 @@ Error: Unboxed record element types must have a representable layout.
(***************************************)
(* Singleton recursive unboxed records *)

(* The check is conservative; we could allow this*)

type 'a safe = #{ a : 'a }
type x = int safe safe
[%%expect{|
type 'a safe = #{ a : 'a; }
Line 2, characters 0-22:
2 | type x = int safe safe
^^^^^^^^^^^^^^^^^^^^^^
Error: The definition of "x" is recursive without boxing:
"x" = "int safe safe",
"int safe safe" contains "int safe"
|}]

(* We could allow these, as although they have unguarded recursion,
they are finite size (thanks to the fact that we represent single-field
records as the layout of the field rather than as a singleton product).
Expand Down

0 comments on commit c5fc9cf

Please sign in to comment.