Skip to content

Enable layout histories #1823

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 13, 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
43 changes: 36 additions & 7 deletions ocaml/testsuite/tests/typing-immediate/immediate.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(* TEST
* expect
*)
(* CR layouts v2.9: all error messages below here are unreviewed *)

module type S = sig type t [@@immediate] end;;
module F (M : S) : S = M;;
Expand Down Expand Up @@ -143,7 +144,11 @@ end;;
Line 2, characters 2-31:
2 | type t = string [@@immediate]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Type string has layout value, which is not a sublayout of immediate.
Error: The layout of Type string is value, because
it equals the primitive value type string.
But the layout of Type string must be a sublayout of immediate, because
of the annotation on the declaration of the type t.

|}];;

(* Cannot directly declare a non-immediate type as immediate (variant) *)
Expand All @@ -154,7 +159,11 @@ end;;
Line 2, characters 2-41:
2 | type t = Foo of int | Bar [@@immediate]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Type t has layout value, which is not a sublayout of immediate.
Error: The layout of Type t is value, because
a boxed variant.
But the layout of Type t must be a sublayout of immediate, because
of the annotation on the declaration of the type t/2.

|}];;

(* Cannot directly declare a non-immediate type as immediate (record) *)
Expand All @@ -165,7 +174,11 @@ end;;
Line 2, characters 2-38:
2 | type t = { foo : int } [@@immediate]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Type t has layout value, which is not a sublayout of immediate.
Error: The layout of Type t is value, because
a boxed record.
But the layout of Type t must be a sublayout of immediate, because
of the annotation on the declaration of the type t/3.

|}];;

(* Not guaranteed that t is immediate, so this is an invalid declaration *)
Expand All @@ -177,7 +190,11 @@ end;;
Line 3, characters 2-26:
3 | type s = t [@@immediate]
^^^^^^^^^^^^^^^^^^^^^^^^
Error: Type t has layout value, which is not a sublayout of immediate.
Error: The layout of Type t is value, because
the default layout for an abstract type.
But the layout of Type t must be a sublayout of immediate, because
of the annotation on the declaration of the type s.

|}];;

(* Can't ascribe to an immediate type signature with a non-immediate type *)
Expand All @@ -198,7 +215,11 @@ Error: Signature mismatch:
type t = string
is not included in
type t : immediate
the first has layout value, which is not a sublayout of immediate.
The layout of the first is value, because
it equals the primitive value type string.
But the layout of the first must be a sublayout of immediate, because
of the annotation on the declaration of the type t.

|}];;

(* Same as above but with explicit signature *)
Expand All @@ -214,7 +235,11 @@ Error: Signature mismatch:
type t = string
is not included in
type t : immediate
the first has layout value, which is not a sublayout of immediate.
The layout of the first is value, because
it equals the primitive value type string.
But the layout of the first must be a sublayout of immediate, because
of the annotation on the declaration of the type t.

|}];;

(* Can't use a non-immediate type even if mutually recursive *)
Expand All @@ -226,7 +251,11 @@ end;;
Line 2, characters 2-26:
2 | type t = s [@@immediate]
^^^^^^^^^^^^^^^^^^^^^^^^
Error: Type s has layout value, which is not a sublayout of immediate.
Error: The layout of Type s is value, because
it equals the primitive value type string.
But the layout of Type s must be a sublayout of immediate, because
of the annotation on the declaration of the type t/2.

|}];;


Expand Down
Loading