Skip to content

Commit

Permalink
Check for type recursion without boxing (#3407)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtjoa authored Jan 10, 2025
1 parent cb290c5 commit c30ec74
Show file tree
Hide file tree
Showing 10 changed files with 619 additions and 160 deletions.
13 changes: 8 additions & 5 deletions testsuite/tests/letrec-check/unboxed.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ Line 2, characters 12-19:
Error: This kind of expression is not allowed as right-hand side of "let rec"
|}];;

(* This test was made to error by disallowing singleton recursive unboxed types.
We keep it in case these are re-allowed, in which case it should error with:
[This kind of expression is not allowed as right-hand side of "let rec"] *)
type r = A of r [@@unboxed]
let rec y = A y;;
[%%expect{|
type r = A of r [@@unboxed]
Line 2, characters 12-15:
2 | let rec y = A y;;
^^^
Error: This kind of expression is not allowed as right-hand side of "let rec"
Line 1, characters 0-27:
1 | type r = A of r [@@unboxed]
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The definition of "r" is recursive without boxing:
"r" contains "r"
|}];;

(* This test is not allowed if 'a' is unboxed, but should be accepted
Expand Down
13 changes: 8 additions & 5 deletions testsuite/tests/typing-layouts-products/letrec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
}
*)

(* This test was made to error by disallowing singleton recursive unboxed types.
We keep it in case these are re-allowed, in which case it should error with:
[This kind of expression is not allowed as right-hand side of "let rec"] *)
type t : value = #{ t : t }
let rec t = #{ t = t }
[%%expect{|
type t = #{ t : t; }
Line 2, characters 12-22:
2 | let rec t = #{ t = t }
^^^^^^^^^^
Error: This kind of expression is not allowed as right-hand side of "let rec"
Line 1, characters 0-27:
1 | type t : value = #{ t : t }
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The definition of "t" is recursive without boxing:
"t" contains "t"
|}]

type bx = { bx : ubx }
Expand Down
Loading

0 comments on commit c30ec74

Please sign in to comment.