Skip to content

Commit f22a166

Browse files
authored
Move float64 to layouts_beta (#1812)
* move float64 to layouts_beta * Revert changes to alpha tests * fix typo in error
1 parent ff470b6 commit f22a166

28 files changed

+1363
-583
lines changed

ocaml/boot/menhir/parser.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ end = struct
11711171

11721172
let assert_unboxed_literals ~loc =
11731173
Language_extension.(
1174-
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Alpha)
1174+
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Beta)
11751175

11761176
let unboxed ~loc x =
11771177
assert_unboxed_literals ~loc:(make_loc loc);
@@ -1216,7 +1216,7 @@ let unboxed_float sloc sign (f, m) =
12161216

12171217
let assert_unboxed_float_type ~loc =
12181218
Language_extension.(
1219-
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Alpha)
1219+
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Beta)
12201220

12211221
let unboxed_float_type sloc tys =
12221222
assert_unboxed_float_type ~loc:(make_loc sloc);

ocaml/parsing/builtin_attributes.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,9 @@ let layout ~legacy_immediate attrs =
478478
| Immediate | Immediate64 ->
479479
check (legacy_immediate
480480
|| Language_extension.(is_at_least Layouts Beta))
481-
| Any | Void | Float64 ->
481+
| Float64 ->
482+
check Language_extension.(is_at_least Layouts Beta)
483+
| Any | Void ->
482484
check Language_extension.(is_at_least Layouts Alpha)
483485

484486
(* The "ocaml.boxed (default)" and "ocaml.unboxed (default)"

ocaml/parsing/builtin_attributes.mli

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ val has_unique: Parsetree.attributes -> (bool,unit) result
175175

176176
val has_once : Parsetree.attributes -> (bool, unit) result
177177

178-
(* [layout] gets the layout in the attributes if one is present. It is the
179-
central point at which the layout extension flags are checked. We always
178+
(* [layout] gets the layout in the attributes if one is present. We always
180179
allow the [value] annotation, even if the layouts extensions are disabled.
181180
If [~legacy_immediate] is true, we allow [immediate] and [immediate64]
182181
attributes even if the layouts extensions are disabled - this is used to
@@ -190,14 +189,20 @@ val has_once : Parsetree.attributes -> (bool, unit) result
190189
- If no layout extensions are on and [~legacy_immediate] is false, this will
191190
always return [Ok None], [Ok (Some Value)], or [Error ...].
192191
- If no layout extensions are on and [~legacy_immediate] is true, this will
193-
error on [void] or [any], but allow [immediate], [immediate64], and [value].
192+
error on [void], [float64], or [any], but allow [immediate], [immediate64],
193+
and [value].
194194
- If the [Layouts_beta] extension is on, this behaves like the previous case
195-
regardless of the value of [~legacy_immediate].
195+
regardless of the value of [~legacy_immediate], except that it allows
196+
[float64].
196197
- If the [Layouts_alpha] extension is on, this can return any layout and
197198
never errors.
198199
199200
Currently, the [Layouts] extension is ignored - it's no different than
200201
turning on no layout extensions.
202+
203+
This is not the only place the layouts extension level is checked. If you're
204+
changing what's allowed in a given level, you may also need to make changes
205+
in the parser, Layouts.get_required_layouts_level, and Typeopt.
201206
*)
202207
(* CR layouts: we should eventually be able to delete ~legacy_immediate (after we
203208
turn on layouts by default). *)

ocaml/parsing/parser.mly

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ end = struct
946946

947947
let assert_unboxed_literals ~loc =
948948
Language_extension.(
949-
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Alpha)
949+
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Beta)
950950

951951
let unboxed ~loc x =
952952
assert_unboxed_literals ~loc:(make_loc loc);
@@ -991,7 +991,7 @@ let unboxed_float sloc sign (f, m) =
991991

992992
let assert_unboxed_float_type ~loc =
993993
Language_extension.(
994-
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Alpha)
994+
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Beta)
995995

996996
let unboxed_float_type sloc tys =
997997
assert_unboxed_float_type ~loc:(make_loc sloc);

ocaml/testsuite/tests/typing-layouts-float64/alloc.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* TEST
2-
flags = "-extension layouts_alpha"
2+
flags = "-extension layouts_beta"
33
* native
44
*)
55

ocaml/testsuite/tests/typing-layouts-float64/basics_alpha.ml renamed to ocaml/testsuite/tests/typing-layouts-float64/basics_alpha_beta.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
(* TEST
2-
flags = "-extension layouts_alpha"
32
* expect
3+
flags = "-extension layouts_alpha"
4+
* expect
5+
flags = "-extension layouts_beta"
46
*)
57

68
(* This file contains typing tests for the layout [float64].
@@ -320,7 +322,7 @@ type f7_4 = [ `A of t_float64 ];;
320322
Line 1, characters 20-29:
321323
1 | type f7_4 = [ `A of t_float64 ];;
322324
^^^^^^^^^
323-
Error: Polymorpic variant constructor argument types must have layout value.
325+
Error: Polymorphic variant constructor argument types must have layout value.
324326
t_float64 has layout float64, which is not a sublayout of value.
325327
|}];;
326328

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

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

ocaml/testsuite/tests/typing-layouts-float64/c_api_alpha.ml renamed to ocaml/testsuite/tests/typing-layouts-float64/c_api.ml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
(* TEST
22
modules = "stubs.c"
3-
flags = "-extension layouts_alpha"
3+
reference = "${test_source_directory}/c_api.reference"
4+
* native
5+
flags = "-extension layouts_alpha"
6+
* bytecode
7+
flags = "-extension layouts_alpha"
8+
* native
9+
flags = "-extension layouts_beta"
10+
* bytecode
11+
flags = "-extension layouts_beta"
412
*)
513

614
(* This file tests using external C functions with float#. *)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
(* TEST
22
flags = "-extension layouts_alpha"
33
* expect
4+
flags = "-extension layouts_beta"
5+
* expect
46
*)
57

68
(* These tests show how potential ambiguities are resolved

ocaml/testsuite/tests/typing-layouts-float64/stdlib_float_u_alpha.ml renamed to ocaml/testsuite/tests/typing-layouts-float64/stdlib_float_u.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
(* TEST
2-
flags = "-extension layouts_alpha"
2+
* native
3+
flags = "-extension layouts_alpha"
4+
* bytecode
5+
flags = "-extension layouts_alpha"
6+
* native
7+
flags = "-extension layouts_beta"
8+
* bytecode
9+
flags = "-extension layouts_beta"
310
*)
411

512
module Float_u = Stdlib__Float_u

ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats.compilers.reference

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

0 commit comments

Comments
 (0)