Skip to content

Commit 798cbb2

Browse files
authored
Support modules of non-legacy modes (#3759)
1 parent 4a634e5 commit 798cbb2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2189
-948
lines changed

driver/compile_common.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ let typecheck_intf info ast =
8787
(Printtyp.printed_signature (Unit_info.source_file info.target))
8888
sg);
8989
ignore (Includemod.signatures info.env ~mark:true
90-
~modes:(Legacy None) sg sg);
90+
~modes:Includemod.modes_unit sg sg);
9191
Typecore.force_delayed_checks ();
9292
Builtin_attributes.warn_unused ();
9393
Warnings.check_fatal ();

jane/doc/extensions/_05-modes/syntax.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ fun x y @ modes -> ..
127127
We don't support `fun x y : ty @ modes -> 42` due to a limitation in the
128128
parser.
129129

130+
## Including signatures
131+
The following includes all items from `S` with extra modality `portable` applied.
132+
```ocaml
133+
include S @@ portable
134+
```
135+
130136
## Expressions
131137
```ocaml
132138
(expression : ty @ modes)

lambda/matching.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2072,7 +2072,7 @@ let get_mod_field modname field =
20722072
Env.add_persistent_structure mod_ident
20732073
(Lazy.force Env.initial)
20742074
in
2075-
let _, env = Env.open_pers_signature modname env in
2075+
let _, _, env = Env.open_pers_signature modname env in
20762076
match Env.find_value_by_name (Longident.Lident field) env with
20772077
| exception Not_found ->
20782078
fatal_errorf "Primitive %s.%s not found." modname field

stdlib/ephemeron.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ module GenHashTable = struct
381381

382382
end
383383

384+
open struct
385+
module DLS = Domain.Safe.DLS
386+
end
387+
384388
module MakeSeededPortable(H: sig @@ portable
385389
type t
386390
type 'a container
@@ -414,8 +418,6 @@ module GenHashTable = struct
414418
else if x * 2 > Sys.max_array_length then x
415419
else power_2_above (x * 2) n
416420

417-
module DLS = Domain.Safe.DLS
418-
419421
let prng_key = DLS.new_key Random.State.make_self_init
420422

421423
let create ?(random = (Hashtbl.is_randomized ())) initial_size =

stdlib/map.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
(* *)
1515
(**************************************************************************)
1616

17+
@@ portable
18+
1719
open! Stdlib
1820

1921
(* NOTE: If this file is map.mli, do not edit it directly! Instead,

stdlib/set.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
(* *)
1515
(**************************************************************************)
1616

17+
@@ portable
18+
1719
open! Stdlib
1820

1921
(* NOTE: If this file is set.mli, do not edit it directly! Instead,

stdlib/stdLabels.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ open! Stdlib
3737

3838
[@@@ocaml.nolabels]
3939

40+
include sig
4041
module Array = ArrayLabels
4142
module Bytes = BytesLabels
4243
module List = ListLabels
4344
module String = StringLabels
45+
end @@ nonportable

stdlib/stdlib.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,7 @@ val do_domain_local_at_exit : (unit -> unit) ref @@ nonportable
14121412
(** {1:modules Standard library modules } *)
14131413

14141414
(*MODULE_ALIASES*)
1415+
include sig
14151416
module Arg = Arg
14161417
module Array = Array
14171418
module ArrayLabels = ArrayLabels
@@ -1483,3 +1484,4 @@ module Type = Type
14831484
module Uchar = Uchar
14841485
module Unit = Unit
14851486
module Weak = Weak
1487+
end @@ nonportable

testsuite/tests/formatting/test_locations.dlocations.ocamlc.reference

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ let rec fib = function | 0 | 1 -> 1 | n -> (fib (n - 1)) + (fib (n - 2))
8989
<def_rec>
9090
pattern (test_locations.ml[17,534+8]..test_locations.ml[17,534+11])
9191
Tpat_var "fib"
92-
value_mode global,many,portable,unyielding,stateful;imply(unique,uncontended,read_write)(modevar#1[aliased,contended,immutable .. unique,uncontended,read_write])
92+
value_mode global,many,portable,unyielding,stateful;imply(unique,uncontended,read_write)(modevar#3[aliased,contended,immutable .. unique,uncontended,read_write])
9393
expression (test_locations.ml[17,534+14]..test_locations.ml[19,572+34])
9494
Texp_function
95-
alloc_mode global,many,portable,unyielding,stateful;id(modevar#7[aliased,contended,immutable .. unique,uncontended,read_write])
95+
alloc_mode global,many,portable,unyielding,stateful;id(modevar#9[aliased,contended,immutable .. unique,uncontended,read_write])
9696
[]
9797
Tfunction_cases (test_locations.ml[17,534+14]..test_locations.ml[19,572+34])
9898
alloc_mode global,many,nonportable,unyielding,stateful;aliased,uncontended,read_write

testsuite/tests/formatting/test_locations.dno-locations.ocamlc.reference

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ let rec fib = function | 0 | 1 -> 1 | n -> (fib (n - 1)) + (fib (n - 2))
8989
<def_rec>
9090
pattern
9191
Tpat_var "fib"
92-
value_mode global,many,portable,unyielding,stateful;imply(unique,uncontended,read_write)(modevar#1[aliased,contended,immutable .. unique,uncontended,read_write])
92+
value_mode global,many,portable,unyielding,stateful;imply(unique,uncontended,read_write)(modevar#3[aliased,contended,immutable .. unique,uncontended,read_write])
9393
expression
9494
Texp_function
95-
alloc_mode global,many,portable,unyielding,stateful;id(modevar#7[aliased,contended,immutable .. unique,uncontended,read_write])
95+
alloc_mode global,many,portable,unyielding,stateful;id(modevar#9[aliased,contended,immutable .. unique,uncontended,read_write])
9696
[]
9797
Tfunction_cases
9898
alloc_mode global,many,nonportable,unyielding,stateful;aliased,uncontended,read_write

0 commit comments

Comments
 (0)