Skip to content

Commit 61ae936

Browse files
dkalinichenko-jsd-kalinichenkogoldfirere
authored
Separability axis basics (#3854)
* separability axis * promote tests * jkind tests * Remove `immutable_separable_value` * Update testsuite/tests/typing-layouts-or-null/separability.ml Co-authored-by: Richard Eisenberg <[email protected]> * Update testsuite/tests/typing-layouts-or-null/separability.ml Co-authored-by: Richard Eisenberg <[email protected]> * Update testsuite/tests/typing-layouts-or-null/separability.ml Co-authored-by: Richard Eisenberg <[email protected]> * Update testsuite/tests/typing-layouts-or-null/separability.ml Co-authored-by: Richard Eisenberg <[email protected]> * promote * address * Update testsuite/tests/typing-layouts-or-null/separability.ml Co-authored-by: Richard Eisenberg <[email protected]> * Update testsuite/tests/typing-layouts-or-null/separability.ml Co-authored-by: Richard Eisenberg <[email protected]> * remove `non_float_value` * update tests * 80 ch limit * 80 ch limit * 80 ch limit * fixes * fix + tests * accept tests * fixes --------- Co-authored-by: Diana Kalinichenko <[email protected]> Co-authored-by: Richard Eisenberg <[email protected]>
1 parent 9077bb8 commit 61ae936

35 files changed

+1409
-253
lines changed

testsuite/tests/parsetree/source_jane_street.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ type 'a abstract
12611261
Lines 2-3, characters 0-67:
12621262
2 | type existential_abstract : immutable_data with (type : value mod portable) abstract =
12631263
3 | | Mk : ('a : value mod portable) abstract -> existential_abstract
1264-
Error: The kind of type "existential_abstract" is value
1264+
Error: The kind of type "existential_abstract" is value mod non_float
12651265
because it's a boxed variant type.
12661266
But the kind of type "existential_abstract" must be a subkind of
12671267
immutable_data with (type : value mod portable) abstract

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Error: The layout of type "a" is value
213213
because of the definition of b at line 2, characters 0-30.
214214
|}]
215215

216-
type a : value mod global aliased many immutable stateless external_ unyielding
216+
type a : value mod global aliased many immutable stateless external_ unyielding non_float
217217
type b : value mod local unique once contended nonportable internal = a
218218
[%%expect{|
219219
type a : immediate
@@ -273,8 +273,8 @@ Error: Layout void is more experimental than allowed by the enabled layouts exte
273273
|}]
274274

275275
type a : immediate
276-
type b : value mod global aliased many immutable stateless unyielding external_ = a
277-
type c : value mod global aliased many immutable stateless unyielding external_
276+
type b : value mod global aliased many immutable stateless unyielding external_ non_float = a
277+
type c : value mod global aliased many immutable stateless unyielding external_ non_float
278278
type d : immediate = c
279279
[%%expect{|
280280
type a : immediate
@@ -284,8 +284,8 @@ type d = c
284284
|}]
285285

286286
type a : immediate64
287-
type b : value mod global aliased many immutable stateless unyielding external64 = a
288-
type c : value mod global aliased many immutable stateless unyielding external64
287+
type b : value mod global aliased many immutable stateless unyielding external64 non_float = a
288+
type c : value mod global aliased many immutable stateless unyielding external64 non_float
289289
type d : immediate64 = c
290290
[%%expect{|
291291
type a : immediate64
@@ -1173,11 +1173,11 @@ type 'a t = { x : 'a @@ global many portable aliased contended; } [@@unboxed]
11731173
[layout_of], we'll be able to give a better jkind to [@@unboxed] types, and
11741174
this will likely improve. *)
11751175

1176-
type 'a t : value mod global immutable stateless many aliased unyielding =
1176+
type 'a t : value mod global immutable stateless many aliased unyielding non_float =
11771177
Foo of 'a @@ global immutable stateless many aliased [@@unboxed]
11781178
[%%expect {|
11791179
Lines 1-2, characters 0-66:
1180-
1 | type 'a t : value mod global immutable stateless many aliased unyielding =
1180+
1 | type 'a t : value mod global immutable stateless many aliased unyielding non_float =
11811181
2 | Foo of 'a @@ global immutable stateless many aliased [@@unboxed]
11821182
Error: The kind of type "t" is value
11831183
because it instantiates an unannotated type parameter of t,
@@ -1271,7 +1271,7 @@ Error: The kind of type "t" is immutable_data with 'a @@ unyielding
12711271
type ('a : value mod aliased) t = ('a : value mod global)
12721272
type ('a : immediate) t = ('a : value)
12731273
type ('a : value) t = ('a : immediate)
1274-
type ('a : value mod external_ stateless many unyielding) t = ('a : value mod immutable global aliased)
1274+
type ('a : value mod external_ stateless many unyielding non_float) t = ('a : value mod immutable global aliased)
12751275
type ('a : value) t = ('a : any)
12761276
type ('a : value) t = ('a : value)
12771277
type ('a : bits32 mod aliased) t = ('a : any mod global)
@@ -1438,7 +1438,7 @@ Line 1, characters 41-51:
14381438
^^^^^^^^^^
14391439
Error: This expression has type "< >" but an expression was expected of type
14401440
"('a : value mod aliased)"
1441-
The kind of < > is value mod global many
1441+
The kind of < > is value mod global many non_float
14421442
because it's the type of an object.
14431443
But the kind of < > must be a subkind of value mod aliased
14441444
because of the annotation on the wildcard _ at line 1, characters 19-36.
@@ -1451,7 +1451,7 @@ Line 1, characters 42-52:
14511451
^^^^^^^^^^
14521452
Error: This expression has type "< >" but an expression was expected of type
14531453
"('a : value mod portable)"
1454-
The kind of < > is value mod global many
1454+
The kind of < > is value mod global many non_float
14551455
because it's the type of an object.
14561456
But the kind of < > must be a subkind of value mod portable
14571457
because of the annotation on the wildcard _ at line 1, characters 19-37.
@@ -1464,7 +1464,7 @@ Line 1, characters 43-53:
14641464
^^^^^^^^^^
14651465
Error: This expression has type "< >" but an expression was expected of type
14661466
"('a : value mod contended)"
1467-
The kind of < > is value mod global many
1467+
The kind of < > is value mod global many non_float
14681468
because it's the type of an object.
14691469
But the kind of < > must be a subkind of value mod contended
14701470
because of the annotation on the wildcard _ at line 1, characters 19-38.
@@ -1477,7 +1477,7 @@ Line 1, characters 43-53:
14771477
^^^^^^^^^^
14781478
Error: This expression has type "< >" but an expression was expected of type
14791479
"('a : value mod external_)"
1480-
The kind of < > is value mod global many
1480+
The kind of < > is value mod global many non_float
14811481
because it's the type of an object.
14821482
But the kind of < > must be a subkind of value mod external_
14831483
because of the annotation on the wildcard _ at line 1, characters 19-38.
@@ -1666,8 +1666,8 @@ Error: This expression has type "int t" but an expression was expected of type
16661666
(*********************************)
16671667
(* Test 15: extensible variants *)
16681668

1669-
(* The best kind an extensible variant can get is [value] *)
1670-
type extensible : value = ..
1669+
(* The best kind an extensible variant can get is [value mod non_float] *)
1670+
type extensible : value mod non_float = ..
16711671
[%%expect{|
16721672
type extensible = ..
16731673
|}]
@@ -1676,10 +1676,10 @@ type extensible = ..
16761676
module M : sig
16771677
type t : immediate with extensible
16781678
end = struct
1679-
type t
1679+
type t : value mod non_float
16801680
end
16811681
[%%expect{|
1682-
module M : sig type t end
1682+
module M : sig type t : value mod non_float end
16831683
|}]
16841684

16851685
(*********************************)
@@ -1721,8 +1721,8 @@ Error: This expression has type "int t" but an expression was expected of type
17211721
(*********************************)
17221722
(* Test 17: extensible variants *)
17231723

1724-
(* The best kind an extensible variant can get is [value] *)
1725-
type extensible : value = ..
1724+
(* The best kind an extensible variant can get is [value mod non_float] *)
1725+
type extensible : value mod non_float = ..
17261726
[%%expect{|
17271727
type extensible = ..
17281728
|}]
@@ -1731,8 +1731,8 @@ type extensible = ..
17311731
module M : sig
17321732
type t : immediate with extensible
17331733
end = struct
1734-
type t
1734+
type t : value mod non_float
17351735
end
17361736
[%%expect{|
1737-
module M : sig type t end
1737+
module M : sig type t : value mod non_float end
17381738
|}]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ Line 1, characters 0-54:
632632
1 | type ('a : immutable_data) t = Flat | Nested of 'a t t
633633
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
634634
Error:
635-
The kind of 'a t is value
635+
The kind of 'a t is value mod non_float
636636
because it's a boxed variant type.
637637
But the kind of 'a t must be a subkind of immutable_data
638638
because of the annotation on 'a in the declaration of the type t.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,5 @@ Error: This expression has type "(string -> string) t"
146146
147147
The first mode-crosses less than the second along:
148148
nullability: mod non_null with string -> string ≰ mod non_null
149+
separability: mod non_float with string -> string ≰ mod separable
149150
|}]

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Line 1, characters 14-35:
9494
^^^^^^^^^^^^^^^^^^^^^
9595
Error: This type "(unit -> unit) option" should be an instance of type
9696
"('a : value mod portable)"
97-
The kind of (unit -> unit) option is value mod immutable
97+
The kind of (unit -> unit) option is value mod immutable non_float
9898
because it's a boxed variant type.
9999
But the kind of (unit -> unit) option must be a subkind of
100100
value mod portable
@@ -312,7 +312,7 @@ Line 1, characters 14-33:
312312
^^^^^^^^^^^^^^^^^^^
313313
Error: This type "(unit -> unit) list" should be an instance of type
314314
"('a : value mod portable)"
315-
The kind of (unit -> unit) list is value mod immutable
315+
The kind of (unit -> unit) list is value mod immutable non_float
316316
because it's a boxed variant type.
317317
But the kind of (unit -> unit) list must be a subkind of
318318
value mod portable
@@ -523,7 +523,7 @@ Line 1, characters 14-35:
523523
^^^^^^^^^^^^^^^^^^^^^
524524
Error: This type "(unit -> unit) iarray" should be an instance of type
525525
"('a : value mod portable)"
526-
The kind of (unit -> unit) iarray is value mod immutable
526+
The kind of (unit -> unit) iarray is value mod immutable non_float
527527
because it is the primitive value type iarray.
528528
But the kind of (unit -> unit) iarray must be a subkind of
529529
value mod portable

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ Line 3, characters 11-25:
201201
^^^^^^^^^^^^^^
202202
Error: This type "(int -> int) u" should be an instance of type
203203
"('a : immutable_data)"
204-
The kind of (int -> int) u is value mod portable immutable
204+
The kind of (int -> int) u is value mod portable immutable non_float
205205
because of the definition of u at line 1, characters 0-33.
206206
But the kind of (int -> int) u must be a subkind of immutable_data
207207
because of the definition of t at line 2, characters 0-28.

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ type t : immutable_data = { x : unit -> unit }
156156
Line 1, characters 0-46:
157157
1 | type t : immutable_data = { x : unit -> unit }
158158
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
159-
Error: The kind of type "t" is value mod immutable
159+
Error: The kind of type "t" is value mod immutable non_float
160160
because it's a boxed record type.
161161
But the kind of type "t" must be a subkind of immutable_data
162162
because of the annotation on the declaration of the type t.
@@ -189,7 +189,7 @@ type t : mutable_data = { x : unit -> unit }
189189
Line 1, characters 0-44:
190190
1 | type t : mutable_data = { x : unit -> unit }
191191
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
192-
Error: The kind of type "t" is value mod immutable
192+
Error: The kind of type "t" is value mod immutable non_float
193193
because it's a boxed record type.
194194
But the kind of type "t" must be a subkind of mutable_data
195195
because of the annotation on the declaration of the type t.
@@ -285,7 +285,7 @@ type 'a t : immutable_data with 'a = { x : 'a -> 'a }
285285
Line 1, characters 0-53:
286286
1 | type 'a t : immutable_data with 'a = { x : 'a -> 'a }
287287
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
288-
Error: The kind of type "t" is value mod immutable
288+
Error: The kind of type "t" is value mod immutable non_float
289289
because it's a boxed record type.
290290
But the kind of type "t" must be a subkind of immutable_data with 'a
291291
because of the annotation on the declaration of the type t.
@@ -625,7 +625,7 @@ Line 1, characters 24-28:
625625
^^^^
626626
Error: This expression has type "(unit -> unit) t"
627627
but an expression was expected of type "('a : value mod portable)"
628-
The kind of (unit -> unit) t is value mod immutable
628+
The kind of (unit -> unit) t is value mod immutable non_float
629629
because of the definition of t at line 1, characters 0-22.
630630
But the kind of (unit -> unit) t must be a subkind of
631631
value mod portable
@@ -650,7 +650,7 @@ Line 1, characters 24-28:
650650
^^^^
651651
Error: This expression has type "(unit -> unit) t"
652652
but an expression was expected of type "('a : value mod external_)"
653-
The kind of (unit -> unit) t is value mod immutable
653+
The kind of (unit -> unit) t is value mod immutable non_float
654654
because of the definition of t at line 1, characters 0-22.
655655
But the kind of (unit -> unit) t must be a subkind of
656656
value mod external_
@@ -745,7 +745,7 @@ Line 1, characters 14-30:
745745
^^^^^^^^^^^^^^^^
746746
Error: This type "(unit -> unit) t" should be an instance of type
747747
"('a : value mod portable)"
748-
The kind of (unit -> unit) t is value mod immutable
748+
The kind of (unit -> unit) t is value mod immutable non_float
749749
because of the definition of t at line 1, characters 0-22.
750750
But the kind of (unit -> unit) t must be a subkind of
751751
value mod portable

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ type t
276276
Line 2, characters 0-44:
277277
2 | type u : immutable_data with t = [`foo of t]
278278
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
279-
Error: The kind of type "[ `foo of t ]" is value
279+
Error: The kind of type "[ `foo of t ]" is value mod non_float
280280
because it's a polymorphic variant type.
281281
But the kind of type "[ `foo of t ]" must be a subkind of immutable_data
282282
with t

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ type t : immutable_data = Foo of (unit -> unit)
160160
Line 1, characters 0-47:
161161
1 | type t : immutable_data = Foo of (unit -> unit)
162162
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
163-
Error: The kind of type "t" is value mod immutable
163+
Error: The kind of type "t" is value mod immutable non_float
164164
because it's a boxed variant type.
165165
But the kind of type "t" must be a subkind of immutable_data
166166
because of the annotation on the declaration of the type t.
@@ -193,7 +193,7 @@ type t : mutable_data = Foo of { x : unit -> unit }
193193
Line 1, characters 0-51:
194194
1 | type t : mutable_data = Foo of { x : unit -> unit }
195195
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
196-
Error: The kind of type "t" is value mod immutable
196+
Error: The kind of type "t" is value mod immutable non_float
197197
because it's a boxed variant type.
198198
But the kind of type "t" must be a subkind of mutable_data
199199
because of the annotation on the declaration of the type t.
@@ -289,7 +289,7 @@ type 'a t : immutable_data with 'a = Foo of { x : 'a -> 'a }
289289
Line 1, characters 0-60:
290290
1 | type 'a t : immutable_data with 'a = Foo of { x : 'a -> 'a }
291291
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
292-
Error: The kind of type "t" is value mod immutable
292+
Error: The kind of type "t" is value mod immutable non_float
293293
because it's a boxed variant type.
294294
But the kind of type "t" must be a subkind of immutable_data with 'a
295295
because of the annotation on the declaration of the type t.
@@ -628,7 +628,7 @@ Line 1, characters 24-28:
628628
^^^^
629629
Error: This expression has type "(unit -> unit) t"
630630
but an expression was expected of type "('a : value mod portable)"
631-
The kind of (unit -> unit) t is value mod immutable
631+
The kind of (unit -> unit) t is value mod immutable non_float
632632
because of the definition of t at line 1, characters 0-21.
633633
But the kind of (unit -> unit) t must be a subkind of
634634
value mod portable
@@ -653,7 +653,7 @@ Line 1, characters 24-28:
653653
^^^^
654654
Error: This expression has type "(unit -> unit) t"
655655
but an expression was expected of type "('a : value mod external_)"
656-
The kind of (unit -> unit) t is value mod immutable
656+
The kind of (unit -> unit) t is value mod immutable non_float
657657
because of the definition of t at line 1, characters 0-21.
658658
But the kind of (unit -> unit) t must be a subkind of
659659
value mod external_
@@ -748,7 +748,7 @@ Line 1, characters 14-30:
748748
^^^^^^^^^^^^^^^^
749749
Error: This type "(unit -> unit) t" should be an instance of type
750750
"('a : value mod portable)"
751-
The kind of (unit -> unit) t is value mod immutable
751+
The kind of (unit -> unit) t is value mod immutable non_float
752752
because of the definition of t at line 1, characters 0-21.
753753
But the kind of (unit -> unit) t must be a subkind of
754754
value mod portable

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,11 +660,11 @@ type t = Immutable.t
660660
module Value = F(struct type t end)
661661
type t : immutable_data = Value.t
662662
[%%expect {|
663-
module Value : sig type t end
663+
module Value : sig type t : value mod non_float end
664664
Line 2, characters 0-33:
665665
2 | type t : immutable_data = Value.t
666666
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
667-
Error: The kind of type "Value.t" is value
667+
Error: The kind of type "Value.t" is value mod non_float
668668
because of the definition of t at line 2, characters 2-34.
669669
But the kind of type "Value.t" must be a subkind of immutable_data
670670
because of the definition of t at line 2, characters 0-33.

0 commit comments

Comments
 (0)