Skip to content

Commit e213962

Browse files
Update comments and tests
1 parent a898318 commit e213962

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

ocaml/testsuite/tests/typing-layouts-non-null-value/arguments.ml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,28 @@ end = struct
7272
let mk x = x
7373
end
7474

75-
(* By default, type parameters to abstract types are nullable: *)
75+
(* CR layouts v3.0: abstract types and type parameters to
76+
abstract types should default to non-null: *)
77+
78+
let _ = Fake_or_null.some (M1.mk 2)
79+
;;
80+
[%%expect{|
81+
module M1 : sig type 'a t val mk : 'a -> 'a t end
82+
Line 14, characters 26-35:
83+
14 | let _ = Fake_or_null.some (M1.mk 2)
84+
^^^^^^^^^
85+
Error: This expression has type int M1.t
86+
but an expression was expected of type ('a : non_null_value)
87+
The layout of int M1.t is value, because
88+
of the definition of t at line 2, characters 2-11.
89+
But the layout of int M1.t must be a sublayout of non_null_value, because
90+
of the definition of some at line 5, characters 2-23.
91+
|}]
7692

7793
let _ = M1.mk (Fake_or_null.some 5)
7894
;;
7995

8096
[%%expect{|
81-
module M1 : sig type 'a t val mk : 'a -> 'a t end
8297
- : int Fake_or_null.t M1.t = <abstr>
8398
|}]
8499

ocaml/testsuite/tests/typing-layouts-non-null-value/basics.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ Error: This expression has type < > but an expression was expected of type
268268
of the definition of id_non_null_value at line 3, characters 4-21.
269269
|}]
270270

271-
(* CR layouts v3.0: [lazy_t] possibly should be non-null. *)
271+
(* CR layouts v3.0: [lazy_t] should be non-null. *)
272272

273273
let _ = id_non_null_value (lazy 3)
274274
;;

ocaml/typing/jkind.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,10 @@ val any : why:any_creation_reason -> t
148148
(** Value of types of this jkind are not retained at all at runtime *)
149149
val void : why:void_creation_reason -> t
150150

151-
(** This is the jkind of normal ocaml values *)
151+
(** This is the jkind of normal ocaml values and null pointers. *)
152152
val value : why:value_creation_reason -> t
153153

154+
(** This is the jkind of normal ocaml values. They have sort Value. *)
154155
val non_null_value : why:non_null_value_creation_reason -> t
155156

156157
(** Values of types of this jkind are immediate on 64-bit platforms; on other

0 commit comments

Comments
 (0)