Skip to content
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

Move float64 to layouts_beta #1812

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
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 ->
goldfirere marked this conversation as resolved.
Show resolved Hide resolved
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].
goldfirere marked this conversation as resolved.
Show resolved Hide resolved
- 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)
ccasin marked this conversation as resolved.
Show resolved Hide resolved

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"
ccasin marked this conversation as resolved.
Show resolved Hide resolved
* 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"
ccasin marked this conversation as resolved.
Show resolved Hide resolved
* 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"
ccasin marked this conversation as resolved.
Show resolved Hide resolved
* 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"
ccasin marked this conversation as resolved.
Show resolved Hide resolved
* 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