Skip to content

Commit 44e40db

Browse files
authored
Graduate mixed blocks from beta (#2664)
* Graduate mixed blocks from beta * Fix from review * Updates from review
1 parent d360662 commit 44e40db

File tree

18 files changed

+465
-3078
lines changed

18 files changed

+465
-3078
lines changed

ocaml/testsuite/tests/typing-layouts-bits32/basics.ml

Lines changed: 90 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,20 @@ Error: This type ('b : value) should be an instance of type ('a : bits32)
202202
(*********************************************************)
203203
(* Test 5: Allowed in some structures in typedecls. *)
204204

205-
(* For the structures they can be put in, see [basics_alpha.ml].
206-
They're separate because mixed blocks requires alpha at the
207-
moment.
208-
*)
205+
type t5_1 = { x : t_bits32 };;
206+
[%%expect{|
207+
type t5_1 = { x : t_bits32; }
208+
|}];;
209+
210+
type t5_2 = { y : int; x : t_bits32 };;
211+
[%%expect{|
212+
type t5_2 = { y : int; x : t_bits32; }
213+
|}];;
214+
215+
type t5_2' = { y : string; x : t_bits32 };;
216+
[%%expect{|
217+
type t5_2' = { y : string; x : t_bits32; }
218+
|}];;
209219

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

230+
231+
type t5_4 = A of t_bits32;;
232+
[%%expect{|
233+
type t5_4 = A of t_bits32
234+
|}];;
235+
236+
type t5_5 = A of int * t_bits32;;
237+
[%%expect{|
238+
type t5_5 = A of int * t_bits32
239+
|}];;
240+
241+
type ('a : bits32) t5_7 = A of int
242+
type ('a : bits32) t5_8 = A of 'a;;
243+
[%%expect{|
244+
type ('a : bits32) t5_7 = A of int
245+
type ('a : bits32) t5_8 = A of 'a
246+
|}]
247+
248+
(* not allowed: value in flat suffix *)
249+
type 'a t_disallowed = A of t_bits32 * 'a
250+
251+
[%%expect{|
252+
Line 1, characters 23-41:
253+
1 | type 'a t_disallowed = A of t_bits32 * 'a
254+
^^^^^^^^^^^^^^^^^^
255+
Error: Expected all flat constructor arguments after non-value argument,
256+
t_bits32, but found boxed argument, 'a.
257+
|}]
258+
220259
type t5_6 = A of t_bits32 [@@unboxed];;
221260
[%%expect{|
222261
Line 1, characters 12-25:
@@ -464,12 +503,54 @@ Line 1, characters 29-35:
464503
Error: Don't know how to untag this type. Only int can be untagged.
465504
|}];;
466505

467-
(*******************************************************)
468-
(* Test 11: Allow bits32 in some extensible variants *)
506+
(*************************************************)
507+
(* Test 11: bits32 banned in extensible variants *)
508+
509+
type t11_1 = ..
510+
511+
type t11_1 += A of t_bits32;;
512+
[%%expect{|
513+
type t11_1 = ..
514+
Line 3, characters 14-27:
515+
3 | type t11_1 += A of t_bits32;;
516+
^^^^^^^^^^^^^
517+
Error: Extensible types can't have fields of unboxed type. Consider wrapping the unboxed fields in a record.
518+
|}]
519+
520+
type t11_1 += B of int32#;;
521+
[%%expect{|
522+
Line 1, characters 14-25:
523+
1 | type t11_1 += B of int32#;;
524+
^^^^^^^^^^^
525+
Error: Extensible types can't have fields of unboxed type. Consider wrapping the unboxed fields in a record.
526+
|}]
527+
528+
type ('a : bits32) t11_2 = ..
529+
530+
type 'a t11_2 += A of int
531+
532+
type 'a t11_2 += B of 'a;;
533+
534+
[%%expect{|
535+
type ('a : bits32) t11_2 = ..
536+
type 'a t11_2 += A of int
537+
Line 5, characters 17-24:
538+
5 | type 'a t11_2 += B of 'a;;
539+
^^^^^^^
540+
Error: Extensible types can't have fields of unboxed type. Consider wrapping the unboxed fields in a record.
541+
|}]
542+
543+
(* not allowed: value in flat suffix *)
544+
type 'a t11_2 += C : 'a * 'b -> 'a t11_2
545+
546+
[%%expect{|
547+
Line 1, characters 17-40:
548+
1 | type 'a t11_2 += C : 'a * 'b -> 'a t11_2
549+
^^^^^^^^^^^^^^^^^^^^^^^
550+
Error: Expected all flat constructor arguments after non-value argument, 'a,
551+
but found boxed argument, 'b.
552+
|}]
469553

470-
(* See [basics_alpha.ml] for these while mixed blocks are
471-
in alpha.
472-
*)
473554
(***************************************)
474555
(* Test 12: bits32 in objects/classes *)
475556

ocaml/testsuite/tests/typing-layouts-bits32/basics_beta.ml

Lines changed: 0 additions & 112 deletions
This file was deleted.

ocaml/testsuite/tests/typing-layouts-bits32/parsing.ml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,12 @@ val f : int32# -> unit = <fun>
1616

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

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

3527
(* int32# works as an argument to normal type constructors, not just

ocaml/testsuite/tests/typing-layouts-bits64/basics.ml

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,20 @@ Error: This type ('b : value) should be an instance of type ('a : bits64)
202202
(****************************************************)
203203
(* Test 5: Allowed in some structures in typedecls. *)
204204

205-
(* See [basics_alpha.ml] and [basics_beta.ml] for now *)
205+
type t5_1 = { x : t_bits64 };;
206+
[%%expect{|
207+
type t5_1 = { x : t_bits64; }
208+
|}];;
209+
210+
type t5_2 = { y : int; x : t_bits64 };;
211+
[%%expect{|
212+
type t5_2 = { y : int; x : t_bits64; }
213+
|}];;
214+
215+
type t5_2' = { y : string; x : t_bits64 };;
216+
[%%expect{|
217+
type t5_2' = { y : string; x : t_bits64; }
218+
|}];;
206219

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

230+
type t5_4 = A of t_bits64;;
231+
[%%expect{|
232+
type t5_4 = A of t_bits64
233+
|}];;
234+
235+
type t5_5 = A of int * t_bits64;;
236+
[%%expect{|
237+
type t5_5 = A of int * t_bits64
238+
|}];;
239+
240+
type ('a : bits64) t5_7 = A of int
241+
type ('a : bits64) t5_8 = A of 'a;;
242+
[%%expect{|
243+
type ('a : bits64) t5_7 = A of int
244+
type ('a : bits64) t5_8 = A of 'a
245+
|}]
246+
247+
(* not allowed: value in flat suffix *)
248+
type 'a t_disallowed = A of t_bits64 * 'a
249+
250+
[%%expect{|
251+
Line 1, characters 23-41:
252+
1 | type 'a t_disallowed = A of t_bits64 * 'a
253+
^^^^^^^^^^^^^^^^^^
254+
Error: Expected all flat constructor arguments after non-value argument,
255+
t_bits64, but found boxed argument, 'a.
256+
|}]
257+
258+
217259
type t5_6 = A of t_bits64 [@@unboxed];;
218260
[%%expect{|
219261
Line 1, characters 12-25:
@@ -461,10 +503,55 @@ Line 1, characters 29-35:
461503
Error: Don't know how to untag this type. Only int can be untagged.
462504
|}];;
463505

464-
(*****************************************************)
465-
(* Test 11: Allow bits64 in some extensible variants *)
506+
(*************************************************)
507+
(* Test 11: bits64 banned in extensible variants *)
508+
509+
(* CR layouts v5.9: Actually allow mixed extensible variant blocks. *)
510+
511+
type t11_1 = ..
512+
513+
type t11_1 += A of t_bits64;;
514+
[%%expect{|
515+
type t11_1 = ..
516+
Line 3, characters 14-27:
517+
3 | type t11_1 += A of t_bits64;;
518+
^^^^^^^^^^^^^
519+
Error: Extensible types can't have fields of unboxed type. Consider wrapping the unboxed fields in a record.
520+
|}]
521+
522+
type t11_1 += B of int64#;;
523+
[%%expect{|
524+
Line 1, characters 14-25:
525+
1 | type t11_1 += B of int64#;;
526+
^^^^^^^^^^^
527+
Error: Extensible types can't have fields of unboxed type. Consider wrapping the unboxed fields in a record.
528+
|}]
466529

467-
(* See [basics_alpha.ml] and [basics_beta.ml] for now *)
530+
type ('a : bits64) t11_2 = ..
531+
532+
type 'a t11_2 += A of int
533+
534+
type 'a t11_2 += B of 'a;;
535+
536+
[%%expect{|
537+
type ('a : bits64) t11_2 = ..
538+
type 'a t11_2 += A of int
539+
Line 5, characters 17-24:
540+
5 | type 'a t11_2 += B of 'a;;
541+
^^^^^^^
542+
Error: Extensible types can't have fields of unboxed type. Consider wrapping the unboxed fields in a record.
543+
|}]
544+
545+
(* not allowed: value in flat suffix *)
546+
type 'a t11_2 += C : 'a * 'b -> 'a t11_2
547+
548+
[%%expect{|
549+
Line 1, characters 17-40:
550+
1 | type 'a t11_2 += C : 'a * 'b -> 'a t11_2
551+
^^^^^^^^^^^^^^^^^^^^^^^
552+
Error: Expected all flat constructor arguments after non-value argument, 'a,
553+
but found boxed argument, 'b.
554+
|}]
468555

469556
(***************************************)
470557
(* Test 12: bits64 in objects/classes *)

0 commit comments

Comments
 (0)