Skip to content

Graduate mixed blocks from beta #2664

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
Jun 6, 2024
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
99 changes: 90 additions & 9 deletions ocaml/testsuite/tests/typing-layouts-bits32/basics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,20 @@ Error: This type ('b : value) should be an instance of type ('a : bits32)
(*********************************************************)
(* Test 5: Allowed in some structures in typedecls. *)

(* For the structures they can be put in, see [basics_alpha.ml].
They're separate because mixed blocks requires alpha at the
moment.
*)
type t5_1 = { x : t_bits32 };;
[%%expect{|
type t5_1 = { x : t_bits32; }
|}];;

type t5_2 = { y : int; x : t_bits32 };;
[%%expect{|
type t5_2 = { y : int; x : t_bits32; }
|}];;

type t5_2' = { y : string; x : t_bits32 };;
[%%expect{|
type t5_2' = { y : string; x : t_bits32; }
|}];;

(* CR layouts 2.5: allow this *)
type t5_3 = { x : t_bits32 } [@@unboxed];;
Expand All @@ -217,6 +227,35 @@ Error: Type t_bits32 has layout bits32.
Unboxed records may not yet contain types of this layout.
|}];;


type t5_4 = A of t_bits32;;
[%%expect{|
type t5_4 = A of t_bits32
|}];;

type t5_5 = A of int * t_bits32;;
[%%expect{|
type t5_5 = A of int * t_bits32
|}];;

type ('a : bits32) t5_7 = A of int
type ('a : bits32) t5_8 = A of 'a;;
[%%expect{|
type ('a : bits32) t5_7 = A of int
type ('a : bits32) t5_8 = A of 'a
|}]

(* not allowed: value in flat suffix *)
type 'a t_disallowed = A of t_bits32 * 'a

[%%expect{|
Line 1, characters 23-41:
1 | type 'a t_disallowed = A of t_bits32 * 'a
^^^^^^^^^^^^^^^^^^
Error: Expected all flat constructor arguments after non-value argument,
t_bits32, but found boxed argument, 'a.
|}]

type t5_6 = A of t_bits32 [@@unboxed];;
[%%expect{|
Line 1, characters 12-25:
Expand Down Expand Up @@ -464,12 +503,54 @@ Line 1, characters 29-35:
Error: Don't know how to untag this type. Only int can be untagged.
|}];;

(*******************************************************)
(* Test 11: Allow bits32 in some extensible variants *)
(*************************************************)
(* Test 11: bits32 banned in extensible variants *)

type t11_1 = ..

type t11_1 += A of t_bits32;;
[%%expect{|
type t11_1 = ..
Line 3, characters 14-27:
3 | type t11_1 += A of t_bits32;;
^^^^^^^^^^^^^
Error: Extensible types can't have fields of unboxed type. Consider wrapping the unboxed fields in a record.
|}]

type t11_1 += B of int32#;;
[%%expect{|
Line 1, characters 14-25:
1 | type t11_1 += B of int32#;;
^^^^^^^^^^^
Error: Extensible types can't have fields of unboxed type. Consider wrapping the unboxed fields in a record.
|}]

type ('a : bits32) t11_2 = ..

type 'a t11_2 += A of int

type 'a t11_2 += B of 'a;;

[%%expect{|
type ('a : bits32) t11_2 = ..
type 'a t11_2 += A of int
Line 5, characters 17-24:
5 | type 'a t11_2 += B of 'a;;
^^^^^^^
Error: Extensible types can't have fields of unboxed type. Consider wrapping the unboxed fields in a record.
|}]

(* not allowed: value in flat suffix *)
type 'a t11_2 += C : 'a * 'b -> 'a t11_2

[%%expect{|
Line 1, characters 17-40:
1 | type 'a t11_2 += C : 'a * 'b -> 'a t11_2
^^^^^^^^^^^^^^^^^^^^^^^
Error: Expected all flat constructor arguments after non-value argument, 'a,
but found boxed argument, 'b.
|}]

(* See [basics_alpha.ml] for these while mixed blocks are
in alpha.
*)
(***************************************)
(* Test 12: bits32 in objects/classes *)

Expand Down
112 changes: 0 additions & 112 deletions ocaml/testsuite/tests/typing-layouts-bits32/basics_beta.ml

This file was deleted.

12 changes: 2 additions & 10 deletions ocaml/testsuite/tests/typing-layouts-bits32/parsing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,12 @@ val f : int32# -> unit = <fun>

type t = C of int32#;;
[%%expect {|
Line 1, characters 9-20:
1 | type t = C of int32#;;
^^^^^^^^^^^
Error: The enabled layouts extension does not allow for mixed constructors.
You must enable -extension layouts_beta to use this feature.
type t = C of int32#
|}];;

type t = C : int32# -> t;;
[%%expect {|
Line 1, characters 9-24:
1 | type t = C : int32# -> t;;
^^^^^^^^^^^^^^^
Error: The enabled layouts extension does not allow for mixed constructors.
You must enable -extension layouts_beta to use this feature.
type t = C : int32# -> t
|}];;

(* int32# works as an argument to normal type constructors, not just
Expand Down
95 changes: 91 additions & 4 deletions ocaml/testsuite/tests/typing-layouts-bits64/basics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,20 @@ Error: This type ('b : value) should be an instance of type ('a : bits64)
(****************************************************)
(* Test 5: Allowed in some structures in typedecls. *)

(* See [basics_alpha.ml] and [basics_beta.ml] for now *)
type t5_1 = { x : t_bits64 };;
[%%expect{|
type t5_1 = { x : t_bits64; }
|}];;

type t5_2 = { y : int; x : t_bits64 };;
[%%expect{|
type t5_2 = { y : int; x : t_bits64; }
|}];;

type t5_2' = { y : string; x : t_bits64 };;
[%%expect{|
type t5_2' = { y : string; x : t_bits64; }
|}];;

(* CR layouts 2.5: allow this *)
type t5_3 = { x : t_bits64 } [@@unboxed];;
Expand All @@ -214,6 +227,35 @@ Error: Type t_bits64 has layout bits64.
Unboxed records may not yet contain types of this layout.
|}];;

type t5_4 = A of t_bits64;;
[%%expect{|
type t5_4 = A of t_bits64
|}];;

type t5_5 = A of int * t_bits64;;
[%%expect{|
type t5_5 = A of int * t_bits64
|}];;

type ('a : bits64) t5_7 = A of int
type ('a : bits64) t5_8 = A of 'a;;
[%%expect{|
type ('a : bits64) t5_7 = A of int
type ('a : bits64) t5_8 = A of 'a
|}]

(* not allowed: value in flat suffix *)
type 'a t_disallowed = A of t_bits64 * 'a

[%%expect{|
Line 1, characters 23-41:
1 | type 'a t_disallowed = A of t_bits64 * 'a
^^^^^^^^^^^^^^^^^^
Error: Expected all flat constructor arguments after non-value argument,
t_bits64, but found boxed argument, 'a.
|}]


type t5_6 = A of t_bits64 [@@unboxed];;
[%%expect{|
Line 1, characters 12-25:
Expand Down Expand Up @@ -461,10 +503,55 @@ Line 1, characters 29-35:
Error: Don't know how to untag this type. Only int can be untagged.
|}];;

(*****************************************************)
(* Test 11: Allow bits64 in some extensible variants *)
(*************************************************)
(* Test 11: bits64 banned in extensible variants *)

(* CR layouts v5.9: Actually allow mixed extensible variant blocks. *)

type t11_1 = ..

type t11_1 += A of t_bits64;;
[%%expect{|
type t11_1 = ..
Line 3, characters 14-27:
3 | type t11_1 += A of t_bits64;;
^^^^^^^^^^^^^
Error: Extensible types can't have fields of unboxed type. Consider wrapping the unboxed fields in a record.
|}]

type t11_1 += B of int64#;;
[%%expect{|
Line 1, characters 14-25:
1 | type t11_1 += B of int64#;;
^^^^^^^^^^^
Error: Extensible types can't have fields of unboxed type. Consider wrapping the unboxed fields in a record.
|}]

(* See [basics_alpha.ml] and [basics_beta.ml] for now *)
type ('a : bits64) t11_2 = ..

type 'a t11_2 += A of int

type 'a t11_2 += B of 'a;;

[%%expect{|
type ('a : bits64) t11_2 = ..
type 'a t11_2 += A of int
Line 5, characters 17-24:
5 | type 'a t11_2 += B of 'a;;
^^^^^^^
Error: Extensible types can't have fields of unboxed type. Consider wrapping the unboxed fields in a record.
|}]

(* not allowed: value in flat suffix *)
type 'a t11_2 += C : 'a * 'b -> 'a t11_2

[%%expect{|
Line 1, characters 17-40:
1 | type 'a t11_2 += C : 'a * 'b -> 'a t11_2
^^^^^^^^^^^^^^^^^^^^^^^
Error: Expected all flat constructor arguments after non-value argument, 'a,
but found boxed argument, 'b.
|}]

(***************************************)
(* Test 12: bits64 in objects/classes *)
Expand Down
Loading
Loading