Skip to content

Commit

Permalink
Move float64 to layouts_beta (#1812)
Browse files Browse the repository at this point in the history
* move float64 to layouts_beta

* Revert changes to alpha tests

* fix typo in error
  • Loading branch information
ccasin authored Sep 13, 2023
1 parent ff470b6 commit f22a166
Show file tree
Hide file tree
Showing 28 changed files with 1,363 additions and 583 deletions.
4 changes: 2 additions & 2 deletions ocaml/boot/menhir/parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ end = struct

let assert_unboxed_literals ~loc =
Language_extension.(
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Alpha)
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Beta)

let unboxed ~loc x =
assert_unboxed_literals ~loc:(make_loc loc);
Expand Down Expand Up @@ -1216,7 +1216,7 @@ let unboxed_float sloc sign (f, m) =

let assert_unboxed_float_type ~loc =
Language_extension.(
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Alpha)
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Beta)

let unboxed_float_type sloc tys =
assert_unboxed_float_type ~loc:(make_loc sloc);
Expand Down
4 changes: 3 additions & 1 deletion ocaml/parsing/builtin_attributes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,9 @@ let layout ~legacy_immediate attrs =
| Immediate | Immediate64 ->
check (legacy_immediate
|| Language_extension.(is_at_least Layouts Beta))
| Any | Void | Float64 ->
| Float64 ->
check Language_extension.(is_at_least Layouts Beta)
| Any | Void ->
check Language_extension.(is_at_least Layouts Alpha)

(* The "ocaml.boxed (default)" and "ocaml.unboxed (default)"
Expand Down
13 changes: 9 additions & 4 deletions ocaml/parsing/builtin_attributes.mli
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ val has_unique: Parsetree.attributes -> (bool,unit) result

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

(* [layout] gets the layout in the attributes if one is present. It is the
central point at which the layout extension flags are checked. We always
(* [layout] gets the layout in the attributes if one is present. We always
allow the [value] annotation, even if the layouts extensions are disabled.
If [~legacy_immediate] is true, we allow [immediate] and [immediate64]
attributes even if the layouts extensions are disabled - this is used to
Expand All @@ -190,14 +189,20 @@ val has_once : Parsetree.attributes -> (bool, unit) result
- If no layout extensions are on and [~legacy_immediate] is false, this will
always return [Ok None], [Ok (Some Value)], or [Error ...].
- If no layout extensions are on and [~legacy_immediate] is true, this will
error on [void] or [any], but allow [immediate], [immediate64], and [value].
error on [void], [float64], or [any], but allow [immediate], [immediate64],
and [value].
- If the [Layouts_beta] extension is on, this behaves like the previous case
regardless of the value of [~legacy_immediate].
regardless of the value of [~legacy_immediate], except that it allows
[float64].
- If the [Layouts_alpha] extension is on, this can return any layout and
never errors.
Currently, the [Layouts] extension is ignored - it's no different than
turning on no layout extensions.
This is not the only place the layouts extension level is checked. If you're
changing what's allowed in a given level, you may also need to make changes
in the parser, Layouts.get_required_layouts_level, and Typeopt.
*)
(* CR layouts: we should eventually be able to delete ~legacy_immediate (after we
turn on layouts by default). *)
Expand Down
4 changes: 2 additions & 2 deletions ocaml/parsing/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ end = struct

let assert_unboxed_literals ~loc =
Language_extension.(
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Alpha)
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Beta)

let unboxed ~loc x =
assert_unboxed_literals ~loc:(make_loc loc);
Expand Down Expand Up @@ -991,7 +991,7 @@ let unboxed_float sloc sign (f, m) =

let assert_unboxed_float_type ~loc =
Language_extension.(
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Alpha)
Jane_syntax_parsing.assert_extension_enabled ~loc Layouts Beta)

let unboxed_float_type sloc tys =
assert_unboxed_float_type ~loc:(make_loc sloc);
Expand Down
2 changes: 1 addition & 1 deletion ocaml/testsuite/tests/typing-layouts-float64/alloc.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* TEST
flags = "-extension layouts_alpha"
flags = "-extension layouts_beta"
* native
*)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
(* TEST
flags = "-extension layouts_alpha"
* expect
flags = "-extension layouts_alpha"
* expect
flags = "-extension layouts_beta"
*)

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

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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
(* TEST
modules = "stubs.c"
flags = "-extension layouts_alpha"
reference = "${test_source_directory}/c_api.reference"
* native
flags = "-extension layouts_alpha"
* bytecode
flags = "-extension layouts_alpha"
* native
flags = "-extension layouts_beta"
* bytecode
flags = "-extension layouts_beta"
*)

(* This file tests using external C functions with float#. *)
Expand Down
2 changes: 2 additions & 0 deletions ocaml/testsuite/tests/typing-layouts-float64/parsing.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
(* TEST
flags = "-extension layouts_alpha"
* expect
flags = "-extension layouts_beta"
* expect
*)

(* These tests show how potential ambiguities are resolved
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
(* TEST
flags = "-extension layouts_alpha"
* native
flags = "-extension layouts_alpha"
* bytecode
flags = "-extension layouts_alpha"
* native
flags = "-extension layouts_beta"
* bytecode
flags = "-extension layouts_beta"
*)

module Float_u = Stdlib__Float_u
Expand Down

This file was deleted.

Loading

0 comments on commit f22a166

Please sign in to comment.