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

Promote val_modalities to Stable #3391

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ let rec fib = function | 0 | 1 -> 1 | n -> (fib (n - 1)) + (fib (n - 2))
<def_rec>
pattern (test_locations.ml[17,534+8]..test_locations.ml[17,534+11])
Tpat_var "fib"
value_mode global,many,nonportable;join(aliased,contended)(modevar#1[aliased,uncontended .. unique,uncontended])
value_mode global,many,nonportable;unique,uncontended
expression (test_locations.ml[17,534+14]..test_locations.ml[19,572+34])
Texp_function
alloc_mode global,many,nonportable;id(modevar#7[aliased,contended .. unique,uncontended])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ let rec fib = function | 0 | 1 -> 1 | n -> (fib (n - 1)) + (fib (n - 2))
<def_rec>
pattern
Tpat_var "fib"
value_mode global,many,nonportable;join(aliased,contended)(modevar#1[aliased,uncontended .. unique,uncontended])
value_mode global,many,nonportable;unique,uncontended
expression
Texp_function
alloc_mode global,many,nonportable;id(modevar#7[aliased,contended .. unique,uncontended])
Expand Down
10 changes: 5 additions & 5 deletions testsuite/tests/parsetree/source_jane_street.ml
Original file line number Diff line number Diff line change
Expand Up @@ -793,9 +793,9 @@ let (~x:x0, ~s, ~(y:int), ..) : (x:int * s:string * y:int * string) =
(~x: 1, ~s: "a", ~y: 2, "ignore me")

[%%expect{|
val x0 : int @@ portable = 1
val s : string @@ portable = "a"
val y : int @@ portable = 2
val x0 : int = 1
val s : string = "a"
val y : int = 2
|}]

module M : sig
Expand Down Expand Up @@ -834,9 +834,9 @@ val foo :
('a : value_or_null) ('b : value_or_null).
'a -> (unit -> 'b) -> (unit -> 'b) -> 'b =
<fun>
val x : int @@ portable = 1
val x : int = 1
val y : int = 2
val x : int @@ portable = 1
val x : int = 1
val y : int = 2
val f : (foo:int * bar:int) -> int = <fun>
val f : (x:int * int) -> int = <fun>
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/templates/basic/bad_arg_impl.reference
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ File "bad_arg_impl.ml", line 1:
Error: The argument module bad_arg_impl.ml
does not match the parameter signature monoid.cmi:
Values do not match:
val append : unit -> unit -> [> `Banana ]
val append : unit -> unit -> [> `Banana ] @@ portable
is not included in
val append : t -> t -> t
The type "unit -> unit -> [> `Banana ]" is not compatible with the type
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/typing-modes/incl_modalities.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* TEST
flags += "-extension mode_alpha";
flags += "-extension mode";
expect;
*)

Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/typing-modes/md_modalities.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* TEST
flags += "-extension mode_alpha";
flags += "-extension mode";
expect;
*)

Expand Down
12 changes: 0 additions & 12 deletions testsuite/tests/typing-modes/modes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -455,18 +455,6 @@ let foo () =
val foo : unit -> unit = <fun>
|}]

(* modalities on normal values requires [-extension mode_alpha] *)
module type S = sig
val x : string -> string @ local @@ foo bar
end
[%%expect{|
Line 2, characters 38-41:
2 | val x : string -> string @ local @@ foo bar
^^^
Error: The extension "mode" is disabled and cannot be used
|}]


(*
* Modification of return modes in argument position
*)
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/typing-modes/portable_interface.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST
readonly_files = "portable_interface.mli use_portable_interface.ml";
flags += "-extension mode_alpha";
flags += "-extension mode";
setup-ocamlc.byte-build-env;
module = "portable_interface.mli";
ocamlc.byte;
Expand Down
14 changes: 5 additions & 9 deletions testsuite/tests/typing-modes/val_modalities.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* TEST
flags = "-extension mode_alpha";
flags = "-extension mode";
expect;
*)

Expand Down Expand Up @@ -62,7 +62,7 @@ module M = struct
let x @ contended = "hello"
end
[%%expect{|
module M : sig val x : string @@ portable contended end
module M : sig val x : string @@ contended end
|}]

(* Testing the defaulting behaviour.
Expand Down Expand Up @@ -171,8 +171,7 @@ module Without_inclusion = struct
let () = portable_use M.x
end
[%%expect{|
module Without_inclusion :
sig module M : sig val x : 'a -> 'a @@ portable end end
module Without_inclusion : sig module M : sig val x : 'a -> 'a end end
|}]

module Without_inclusion = struct
Expand Down Expand Up @@ -265,10 +264,7 @@ module Close_over_value = struct
end
[%%expect{|
module Close_over_value :
sig
module M : sig val x : string @@ portable end
val foo : unit -> unit @@ portable
end
sig module M : sig val x : string end val foo : unit -> unit end
|}]

(* CR mode-crossing: This is used for the below test in place of a mutable record. *)
Expand Down Expand Up @@ -855,7 +851,7 @@ module M_portable = struct
end
[%%expect{|
module M_nonportable : sig val f : unit -> unit end
module M_portable : sig val f : unit -> unit @@ portable end
module M_portable : sig val f : unit -> unit end
|}]

let (foo @ portable) () =
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/typing-modes/val_modalities_floor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ strongest instead of legacy *)
";
{
setup-ocamlopt.byte-build-env;
flags = "-extension mode_alpha";
flags = "-extension mode";

{
src = "def_portable.ml";
Expand Down
6 changes: 3 additions & 3 deletions testsuite/tests/typing-unique/rbtree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,10 @@ module Make_Okasaki :
val fold :
'a 'b ('c : value_or_null).
('a -> 'b -> 'c -> 'c) -> 'c -> ('a, 'b) tree -> 'c
val balance_left : ('a, 'b) tree -> ('a, 'b) tree @@ portable
val balance_right : ('a, 'b) tree -> ('a, 'b) tree @@ portable
val balance_left : ('a, 'b) tree -> ('a, 'b) tree
val balance_right : ('a, 'b) tree -> ('a, 'b) tree
val ins : Ord.t -> 'a -> (Ord.t, 'a) tree -> (Ord.t, 'a) tree
val set_black : ('a, 'b) tree -> ('a, 'b) tree @@ portable
val set_black : ('a, 'b) tree -> ('a, 'b) tree
val insert : Ord.t -> 'a -> (Ord.t, 'a) tree -> (Ord.t, 'a) tree
end
Line 110, characters 16-52:
Expand Down
2 changes: 1 addition & 1 deletion typing/printtyp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2160,7 +2160,7 @@ let tree_of_value_description id decl =
(* Important: process the fvs *after* the type; tree_of_type_scheme
resets the naming context *)
let snap = Btype.snapshot () in
let moda = Mode.Modality.Value.zap_to_floor decl.val_modalities in
let moda = Mode.Modality.Value.zap_to_id decl.val_modalities in
let qtvs = extract_qtvs [decl.val_type] in
let apparent_arity =
let rec count n typ =
Expand Down
2 changes: 1 addition & 1 deletion typing/typedecl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3096,7 +3096,7 @@ let transl_value_decl env loc ~sig_modalities valdecl =
let modalities =
match valdecl.pval_modalities with
| [] -> sig_modalities
| l -> Typemode.transl_modalities ~maturity:Alpha Immutable
| l -> Typemode.transl_modalities ~maturity:Stable Immutable
valdecl.pval_attributes l
in
let modalities = Mode.Modality.Value.of_const modalities in
Expand Down
10 changes: 5 additions & 5 deletions typing/typemod.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ let apply_pmd_modalities env sig_modalities pmd_modalities mty =
match pmd_modalities with
| [] -> sig_modalities
| _ :: _ ->
Typemode.transl_modalities ~maturity:Alpha Immutable [] pmd_modalities
Typemode.transl_modalities ~maturity:Stable Immutable [] pmd_modalities
in
(*
Workaround for pmd_modalities
Expand Down Expand Up @@ -1248,7 +1248,7 @@ and approx_sig_items env ssg=
| [] -> sg
| _ ->
let modalities =
Typemode.transl_modalities ~maturity:Alpha Immutable [] moda
Typemode.transl_modalities ~maturity:Stable Immutable [] moda
in
let recursive =
not @@ Builtin_attributes.has_attribute "no_recursive_modalities" attrs
Expand Down Expand Up @@ -1750,7 +1750,7 @@ and transl_signature env {psg_items; psg_modalities; psg_loc} =
let names = Signature_names.create () in

let sig_modalities =
Typemode.transl_modalities ~maturity:Alpha Immutable [] psg_modalities
Typemode.transl_modalities ~maturity:Stable Immutable [] psg_modalities
in

let transl_include ~loc env sig_acc sincl modalities =
Expand All @@ -1776,7 +1776,7 @@ and transl_signature env {psg_items; psg_modalities; psg_loc} =
match modalities with
| [] -> sig_modalities
| _ ->
Typemode.transl_modalities ~maturity:Alpha Immutable [] modalities
Typemode.transl_modalities ~maturity:Stable Immutable [] modalities
in
let sg =
if not @@ Mode.Modality.Value.Const.is_id modalities then
Expand Down Expand Up @@ -2563,7 +2563,7 @@ let simplify_app_summary app_view = match app_view.arg with
| false, None -> Includemod.Error.Anonymous, mty

let maybe_infer_modalities ~loc ~env ~md_mode ~mode =
if Language_extension.(is_at_least Mode Alpha) then begin
if Language_extension.(is_at_least Mode Stable) then begin
(* Upon construction, for comonadic (prescriptive) axes, module
must be weaker than the values therein, for otherwise operations
would be allowed to performed on the module (and extended to the
Expand Down
Loading