-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consider modalities when adding baggage to with-kinds
If a field has a constant modality, or a type is annotated with a constant modality, then skip that type when adding it as baggage to the kind, both when converting user-written kind annotations and inferring kinds on types. The guts of this is a big, ugly pattern match on Jkind_axis and Modes.Modality.Const.axis, which ideally can go away or get much simpler with a refactor to unify these two types, but I decided to do it this way for now to get something working that's known-correct, and refactor under green
- Loading branch information
1 parent
baf79fa
commit 7f8173c
Showing
10 changed files
with
180 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
(* TEST | ||
flags = "-extension layouts_alpha"; | ||
expect; | ||
*) | ||
let use_uncontended : 'a @ uncontended -> unit = fun _ -> () | ||
let use_portable : 'a @ portable -> unit = fun _ -> () | ||
let cross_uncontended : ('a : value mod uncontended) -> unit = fun _ -> () | ||
type ('a : value mod uncontended) require_uncontended | ||
[%%expect{| | ||
val use_uncontended : ('a : value_or_null). 'a -> unit = <fun> | ||
val use_portable : ('a : value_or_null). 'a @ portable -> unit = <fun> | ||
val cross_uncontended : ('a : value mod uncontended). 'a -> unit = <fun> | ||
type ('a : value mod uncontended) require_uncontended | ||
|}] | ||
|
||
type 'a t = { contended : 'a @@ contended } | ||
[%%expect{| | ||
type 'a t = { contended : 'a @@ contended; } | ||
|}] | ||
|
||
type t_test = int t require_uncontended | ||
type t_test = int ref t require_uncontended | ||
[%%expect{| | ||
type t_test = int t require_uncontended | ||
type t_test = int ref t require_uncontended | ||
|}] | ||
|
||
let foo (t : int ref t @@ contended) = use_uncontended t | ||
[%%expect{| | ||
val foo : int ref t @ contended -> unit = <fun> | ||
|}] | ||
|
||
let foo (t : int ref t @@ contended) = use_uncontended t.contended | ||
[%%expect{| | ||
Line 1, characters 55-66: | ||
1 | let foo (t : int ref t @@ contended) = use_uncontended t.contended | ||
^^^^^^^^^^^ | ||
Error: This value is "contended" but expected to be "uncontended". | ||
|}] | ||
|
||
let foo (t : int ref t @@ contended) = cross_uncontended t | ||
[%%expect{| | ||
val foo : int ref t @ contended -> unit = <fun> | ||
|}] | ||
|
||
let foo (t : int t @@ nonportable) = use_portable t | ||
[%%expect{| | ||
val foo : int t -> unit = <fun> | ||
|}] | ||
|
||
let foo (t : _ t @@ nonportable) = use_portable t | ||
[%%expect{| | ||
Line 1, characters 48-49: | ||
1 | let foo (t : _ t @@ nonportable) = use_portable t | ||
^ | ||
Error: This value is "nonportable" but expected to be "portable". | ||
|}] | ||
|
||
type 'a t : immutable_data with 'a @@ many = { x : 'a @@ many } | ||
type 'a t : immutable_data with 'a @@ uncontended = { x : 'a @@ uncontended } | ||
type 'a t : immutable_data with 'a @@ portable = { x : 'a @@ portable } | ||
[%%expect{| | ||
Line 1, characters 0-63: | ||
1 | type 'a t : immutable_data with 'a @@ many = { x : 'a @@ many } | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
Error: The kind of type "t" is | ||
value mod local with 'a many uncontended with 'a portable with 'a | ||
internal with 'a | ||
because it's a boxed record type. | ||
But the kind of type "t" must be a subkind of | ||
value mod local with 'a many uncontended with 'a portable with 'a | ||
internal with 'a | ||
because of the annotation on the declaration of the type t. | ||
|}] | ||
(* CR layouts v2.8: this should be accepted *) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters