Skip to content

Commit f15cd33

Browse files
authored
Modality.Value.Const should behave like a product (#3961)
1 parent 3a8999d commit f15cd33

23 files changed

+360
-330
lines changed

testsuite/tests/typing-jkind-bounds/basics.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ type ('a : immediate) t : value mod global = { mutable x : 'a }
990990
Line 1, characters 0-63:
991991
1 | type ('a : immediate) t : value mod global = { mutable x : 'a }
992992
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
993-
Error: The kind of type "t" is mutable_data with 'a @@ many unyielding
993+
Error: The kind of type "t" is mutable_data with 'a @@ unyielding many
994994
because it's a boxed record type.
995995
But the kind of type "t" must be a subkind of value mod global
996996
because of the annotation on the declaration of the type t.
@@ -1004,7 +1004,7 @@ type ('a : immediate) t : value mod aliased = { mutable x : 'a }
10041004
Line 1, characters 0-64:
10051005
1 | type ('a : immediate) t : value mod aliased = { mutable x : 'a }
10061006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1007-
Error: The kind of type "t" is mutable_data with 'a @@ many unyielding
1007+
Error: The kind of type "t" is mutable_data with 'a @@ unyielding many
10081008
because it's a boxed record type.
10091009
But the kind of type "t" must be a subkind of value mod aliased
10101010
because of the annotation on the declaration of the type t.
@@ -1018,7 +1018,7 @@ type ('a : immediate) t : value mod contended = { mutable x : 'a }
10181018
Line 1, characters 0-66:
10191019
1 | type ('a : immediate) t : value mod contended = { mutable x : 'a }
10201020
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1021-
Error: The kind of type "t" is mutable_data with 'a @@ many unyielding
1021+
Error: The kind of type "t" is mutable_data with 'a @@ unyielding many
10221022
because it's a boxed record type.
10231023
But the kind of type "t" must be a subkind of value mod contended
10241024
because of the annotation on the declaration of the type t.
@@ -1032,7 +1032,7 @@ type ('a : immediate) t : value mod external_ = { mutable x : 'a }
10321032
Line 1, characters 0-66:
10331033
1 | type ('a : immediate) t : value mod external_ = { mutable x : 'a }
10341034
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1035-
Error: The kind of type "t" is mutable_data with 'a @@ many unyielding
1035+
Error: The kind of type "t" is mutable_data with 'a @@ unyielding many
10361036
because it's a boxed record type.
10371037
But the kind of type "t" must be a subkind of value mod external_
10381038
because of the annotation on the declaration of the type t.
@@ -1046,7 +1046,7 @@ type ('a : immediate) t : value mod external64 = { mutable x : 'a }
10461046
Line 1, characters 0-67:
10471047
1 | type ('a : immediate) t : value mod external64 = { mutable x : 'a }
10481048
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1049-
Error: The kind of type "t" is mutable_data with 'a @@ many unyielding
1049+
Error: The kind of type "t" is mutable_data with 'a @@ unyielding many
10501050
because it's a boxed record type.
10511051
But the kind of type "t" must be a subkind of value mod external64
10521052
because of the annotation on the declaration of the type t.

testsuite/tests/typing-jkind-bounds/composite.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Line 1, characters 13-20:
189189
1 | let foo (t : int ref t @ contended) = use_uncontended t
190190
^^^^^^^
191191
Error: This type "int ref" should be an instance of type "('a : immutable_data)"
192-
The kind of int ref is mutable_data with int @@ many unyielding.
192+
The kind of int ref is mutable_data with int @@ unyielding many.
193193
But the kind of int ref must be a subkind of immutable_data
194194
because of the definition of t at line 1, characters 0-46.
195195

@@ -341,7 +341,7 @@ Line 1, characters 13-20:
341341
1 | let foo (t : int ref t @ contended) = use_uncontended t
342342
^^^^^^^
343343
Error: This type "int ref" should be an instance of type "('a : immutable_data)"
344-
The kind of int ref is mutable_data with int @@ many unyielding.
344+
The kind of int ref is mutable_data with int @@ unyielding many.
345345
But the kind of int ref must be a subkind of immutable_data
346346
because of the definition of t at line 1, characters 0-73.
347347

testsuite/tests/typing-jkind-bounds/predef.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ type 'a t : mutable_data = 'a ref
176176
Line 1, characters 0-33:
177177
1 | type 'a t : mutable_data = 'a ref
178178
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
179-
Error: The kind of type "'a ref" is mutable_data with 'a @@ many unyielding.
179+
Error: The kind of type "'a ref" is mutable_data with 'a @@ unyielding many.
180180
But the kind of type "'a ref" must be a subkind of mutable_data
181181
because of the definition of t at line 1, characters 0-33.
182182

@@ -199,7 +199,7 @@ Line 1, characters 14-21:
199199
^^^^^^^
200200
Error: This type "int ref" should be an instance of type
201201
"('a : value mod portable)"
202-
The kind of int ref is mutable_data with int @@ many unyielding.
202+
The kind of int ref is mutable_data with int @@ unyielding many.
203203
But the kind of int ref must be a subkind of value mod portable
204204
because of the definition of require_portable at line 10, characters 0-47.
205205

@@ -223,7 +223,7 @@ Line 1, characters 14-21:
223223
^^^^^^^
224224
Error: This type "int ref" should be an instance of type
225225
"('a : value mod contended)"
226-
The kind of int ref is mutable_data with int @@ many unyielding.
226+
The kind of int ref is mutable_data with int @@ unyielding many.
227227
But the kind of int ref must be a subkind of value mod contended
228228
because of the definition of require_contended at line 9, characters 0-49.
229229

testsuite/tests/typing-jkind-bounds/printing.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Line 3, characters 11-12:
179179
^
180180
Error: This type "a" = "int ref" should be an instance of type
181181
"('a : immutable_data)"
182-
The kind of a is mutable_data with int @@ many unyielding.
182+
The kind of a is mutable_data with int @@ unyielding many.
183183
But the kind of a must be a subkind of immutable_data
184184
because of the definition of t at line 2, characters 0-28.
185185

@@ -343,15 +343,15 @@ Error: Signature mismatch:
343343
Modules do not match:
344344
sig type 'a t : mutable_data with 'a end
345345
is not included in
346-
sig type 'a t : mutable_data with 'a @@ many unyielding end
346+
sig type 'a t : mutable_data with 'a @@ unyielding many end
347347
Type declarations do not match:
348348
type 'a t : mutable_data with 'a
349349
is not included in
350-
type 'a t : mutable_data with 'a @@ many unyielding
350+
type 'a t : mutable_data with 'a @@ unyielding many
351351
The kind of the first is mutable_data with 'a
352352
because of the definition of t at line 4, characters 2-34.
353353
But the kind of the first must be a subkind of mutable_data
354-
with 'a @@ many unyielding
354+
with 'a @@ unyielding many
355355
because of the definition of t at line 2, characters 2-40.
356356

357357
The first mode-crosses less than the second along:
@@ -423,14 +423,14 @@ Lines 3-5, characters 6-3:
423423
5 | end
424424
Error: Signature mismatch:
425425
Modules do not match:
426-
sig type 'a t : mutable_data with 'a @@ many unyielding end
426+
sig type 'a t : mutable_data with 'a @@ unyielding many end
427427
is not included in
428428
sig type 'a t : immutable_data with 'a end
429429
Type declarations do not match:
430-
type 'a t : mutable_data with 'a @@ many unyielding
430+
type 'a t : mutable_data with 'a @@ unyielding many
431431
is not included in
432432
type 'a t : immutable_data with 'a
433-
The kind of the first is mutable_data with 'a @@ many unyielding
433+
The kind of the first is mutable_data with 'a @@ unyielding many
434434
because of the definition of t at line 4, characters 2-40.
435435
But the kind of the first must be a subkind of immutable_data with 'a
436436
because of the definition of t at line 2, characters 2-56.

testsuite/tests/typing-jkind-bounds/records.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ type 'a t : immutable_data = { mutable x : 'a }
128128
Line 1, characters 0-47:
129129
1 | type 'a t : immutable_data = { mutable x : 'a }
130130
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131-
Error: The kind of type "t" is mutable_data with 'a @@ many unyielding
131+
Error: The kind of type "t" is mutable_data with 'a @@ unyielding many
132132
because it's a boxed record type.
133133
But the kind of type "t" must be a subkind of immutable_data
134134
because of the annotation on the declaration of the type t.
@@ -270,7 +270,7 @@ type 'a t : immutable_data with 'a = { mutable x : 'a }
270270
Line 1, characters 0-55:
271271
1 | type 'a t : immutable_data with 'a = { mutable x : 'a }
272272
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
273-
Error: The kind of type "t" is mutable_data with 'a @@ many unyielding
273+
Error: The kind of type "t" is mutable_data with 'a @@ unyielding many
274274
because it's a boxed record type.
275275
But the kind of type "t" must be a subkind of immutable_data with 'a
276276
because of the annotation on the declaration of the type t.

testsuite/tests/typing-jkind-bounds/subsumption/basics.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ Error: Signature mismatch:
176176
Modules do not match:
177177
sig type 'a t : mutable_data with 'a end
178178
is not included in
179-
sig type 'a t : mutable_data with 'a @@ many unyielding end
179+
sig type 'a t : mutable_data with 'a @@ unyielding many end
180180
Type declarations do not match:
181181
type 'a t : mutable_data with 'a
182182
is not included in
183-
type 'a t : mutable_data with 'a @@ many unyielding
183+
type 'a t : mutable_data with 'a @@ unyielding many
184184
The kind of the first is mutable_data with 'a
185185
because of the definition of t at line 4, characters 2-34.
186186
But the kind of the first must be a subkind of mutable_data
187-
with 'a @@ many unyielding
187+
with 'a @@ unyielding many
188188
because of the definition of t at line 2, characters 2-40.
189189

190190
The first mode-crosses less than the second along:
@@ -198,7 +198,7 @@ end = struct
198198
type 'a t : mutable_data with 'a @@ many unyielding
199199
end
200200
[%%expect {|
201-
module M : sig type 'a t : mutable_data with 'a @@ many unyielding end
201+
module M : sig type 'a t : mutable_data with 'a @@ unyielding many end
202202
|}]
203203

204204
(* CR layouts v2.8: 'a u's kind should get normalized to just immutable_data *)

testsuite/tests/typing-jkind-bounds/subsumption/constraint.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Error: Signature mismatch:
141141
type 'a t = Foo of 'a constraint 'a = 'b ref
142142
is not included in
143143
type 'a t : immutable_data with 'b constraint 'a = 'b ref
144-
The kind of the first is mutable_data with 'b @@ many unyielding
144+
The kind of the first is mutable_data with 'b @@ unyielding many
145145
because of the definition of t at line 4, characters 2-46.
146146
But the kind of the first must be a subkind of immutable_data with 'b
147147
because of the definition of t at line 2, characters 2-59.

testsuite/tests/typing-jkind-bounds/subsumption/functors.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Line 4, characters 0-48:
5959
4 | type 'a t : immutable_data with 'a = 'a F(Ref).t
6060
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6161
Error: The kind of type "'a F(Ref).t" is mutable_data
62-
with 'a @@ many unyielding
62+
with 'a @@ unyielding many
6363
because of the definition of t at line 2, characters 2-40.
6464
But the kind of type "'a F(Ref).t" must be a subkind of immutable_data
6565
with 'a
@@ -80,7 +80,7 @@ Line 4, characters 0-38:
8080
4 | type 'a t : mutable_data = 'a F(Ref).t
8181
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8282
Error: The kind of type "'a F(Ref).t" is mutable_data
83-
with 'a @@ many unyielding
83+
with 'a @@ unyielding many
8484
because of the definition of t at line 2, characters 2-40.
8585
But the kind of type "'a F(Ref).t" must be a subkind of mutable_data
8686
because of the definition of t at line 4, characters 0-38.

testsuite/tests/typing-jkind-bounds/subsumption/modalities.ml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,21 @@ end = struct
367367
type 'a t : immutable_data with 'a @@ portable contended portable
368368
end
369369
[%%expect {|
370+
Line 4, characters 40-48:
371+
4 | type 'a t : immutable_data with 'a @@ portable contended portable
372+
^^^^^^^^
373+
Warning 213: This portability is overriden by portable later.
374+
375+
Line 4, characters 40-48:
376+
4 | type 'a t : immutable_data with 'a @@ portable contended portable
377+
^^^^^^^^
378+
Warning 213: This portability is overriden by portable later.
379+
380+
Line 4, characters 40-48:
381+
4 | type 'a t : immutable_data with 'a @@ portable contended portable
382+
^^^^^^^^
383+
Warning 213: This portability is overriden by portable later.
384+
370385
module M : sig type 'a t : immutable_data with 'a @@ portable end
371386
|}]
372387

testsuite/tests/typing-jkind-bounds/variants.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ type 'a t : immutable_data = Foo of { mutable x : 'a }
132132
Line 1, characters 0-54:
133133
1 | type 'a t : immutable_data = Foo of { mutable x : 'a }
134134
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
135-
Error: The kind of type "t" is mutable_data with 'a @@ many unyielding
135+
Error: The kind of type "t" is mutable_data with 'a @@ unyielding many
136136
because it's a boxed variant type.
137137
But the kind of type "t" must be a subkind of immutable_data
138138
because of the annotation on the declaration of the type t.
@@ -274,7 +274,7 @@ type 'a t : immutable_data with 'a = Foo of { mutable x : 'a }
274274
Line 1, characters 0-62:
275275
1 | type 'a t : immutable_data with 'a = Foo of { mutable x : 'a }
276276
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
277-
Error: The kind of type "t" is mutable_data with 'a @@ many unyielding
277+
Error: The kind of type "t" is mutable_data with 'a @@ unyielding many
278278
because it's a boxed variant type.
279279
But the kind of type "t" must be a subkind of immutable_data with 'a
280280
because of the annotation on the declaration of the type t.

testsuite/tests/typing-layouts/allow_any.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,10 @@ Lines 1-2, characters 0-34:
385385
Error: This variant or record definition does not match that of type "'a t"
386386
They have different unsafe mode crossing behavior:
387387
Both specify [@@unsafe_allow_any_mode_crossing], but their bounds are not equal
388-
the original has: mod many portable unyielding stateless contended
389-
immutable with 'a
390-
but this has: mod many portable unyielding stateless contended
391-
immutable
388+
the original has: mod unyielding many stateless portable immutable
389+
contended with 'a
390+
but this has: mod unyielding many stateless portable immutable
391+
contended
392392
|}]
393393

394394
type ('a, 'b) arity_2 : immutable_data with 'b = { x : 'a }
@@ -406,10 +406,10 @@ Error: This variant or record definition does not match that of type
406406
"('a, 'b) arity_2"
407407
They have different unsafe mode crossing behavior:
408408
Both specify [@@unsafe_allow_any_mode_crossing], but their bounds are not equal
409-
the original has: mod many portable unyielding stateless contended
410-
immutable with 'b
411-
but this has: mod many portable unyielding stateless contended
412-
immutable with 'a
409+
the original has: mod unyielding many stateless portable immutable
410+
contended with 'b
411+
but this has: mod unyielding many stateless portable immutable
412+
contended with 'a
413413
|}]
414414

415415
(* mcomp *)

testsuite/tests/typing-modal-kinds/basics.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ Line 1, characters 10-19:
934934
^^^^^^^^^
935935
Error: This type "int t ref" should be an instance of type
936936
"('a : value mod contended)"
937-
The kind of int t ref is mutable_data with int t @@ many unyielding.
937+
The kind of int t ref is mutable_data with int t @@ unyielding many.
938938
But the kind of int t ref must be a subkind of value mod contended
939939
because of the definition of require_contended at line 1, characters 0-49.
940940

testsuite/tests/typing-modes/modes.ml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,12 @@ Error: Unrecognized modality foo.
321321
|}]
322322

323323
type t = Foo of global_ string @@ global
324-
(* CR reduced-modality: this should warn. *)
325324
[%%expect{|
325+
Line 1, characters 16-23:
326+
1 | type t = Foo of global_ string @@ global
327+
^^^^^^^
328+
Warning 213: This locality is overriden by global later.
329+
326330
type t = Foo of global_ string
327331
|}]
328332

@@ -346,8 +350,12 @@ Error: Unrecognized modality foo.
346350
type r = {
347351
global_ x : string @@ global
348352
}
349-
(* CR reduced-modality: this should warn. *)
350353
[%%expect{|
354+
Line 2, characters 2-9:
355+
2 | global_ x : string @@ global
356+
^^^^^^^
357+
Warning 213: This locality is overriden by global later.
358+
351359
type r = { global_ x : string; }
352360
|}]
353361

@@ -369,8 +377,12 @@ type r = { x : string @@ global many aliased; }
369377
type r = {
370378
x : string @@ aliased global many aliased
371379
}
372-
(* CR reduced-modality: this should warn. *)
373380
[%%expect{|
381+
Line 2, characters 16-23:
382+
2 | x : string @@ aliased global many aliased
383+
^^^^^^^
384+
Warning 213: This uniqueness is overriden by aliased later.
385+
374386
type r = { x : string @@ global many aliased; }
375387
|}]
376388

testsuite/tests/typing-modes/mutable.ml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,54 @@ Line 2, characters 31-32:
1616
Error: This value escapes its region.
1717
|}]
1818

19+
(* you can override those implied modalities *)
20+
type r = {mutable s : string @@ local}
21+
let foo (local_ s) = exclave_ {s}
22+
[%%expect{|
23+
type r = { mutable s : string @@ local; }
24+
val foo : local_ string -> local_ r = <fun>
25+
|}]
26+
27+
type r = {mutable s : string @@ global}
28+
[%%expect{|
29+
type r = { mutable s : string; }
30+
|}]
31+
32+
type r = {mutable s : string @@ global yielding}
33+
[%%expect{|
34+
type r = { mutable s : string @@ yielding; }
35+
|}]
36+
37+
type r = {mutable s : string @@ yielding global}
38+
[%%expect{|
39+
type r = { mutable s : string @@ yielding; }
40+
|}]
41+
42+
type r = {mutable s : string @@ yielding}
43+
[%%expect{|
44+
type r = { mutable s : string @@ yielding; }
45+
|}]
46+
47+
type r = {mutable s : string @@ local yielding}
48+
[%%expect{|
49+
type r = { mutable s : string @@ local; }
50+
|}]
51+
52+
type r = {mutable s : string @@ yielding local}
53+
[%%expect{|
54+
type r = { mutable s : string @@ local; }
55+
|}]
56+
57+
type r = {mutable s : string @@ local unyielding}
58+
[%%expect{|
59+
type r = { mutable s : string @@ local unyielding; }
60+
|}]
61+
62+
type r = {mutable s : string @@ unyielding local}
63+
[%%expect{|
64+
type r = { mutable s : string @@ local unyielding; }
65+
|}]
66+
1967
(* [@no_mutable_implied_modalities] disables those implied modalities on the
2068
comonadic axes, and allows us to test [mutable] alone *)
2169

0 commit comments

Comments
 (0)