File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
testsuite/tests/typing-layouts-non-null-value Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -72,13 +72,28 @@ end = struct
72
72
let mk x = x
73
73
end
74
74
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
+ | }]
76
92
77
93
let _ = M1. mk (Fake_or_null. some 5 )
78
94
;;
79
95
80
96
[%% expect{|
81
- module M1 : sig type 'a t val mk : 'a -> 'a t end
82
97
- : int Fake_or_null. t M1. t = < abstr>
83
98
| }]
84
99
Original file line number Diff line number Diff line change @@ -268,7 +268,7 @@ Error: This expression has type < > but an expression was expected of type
268
268
of the definition of id_non_null_value at line 3 , characters 4 -21.
269
269
| }]
270
270
271
- (* CR layouts v3.0: [lazy_t] possibly should be non-null. *)
271
+ (* CR layouts v3.0: [lazy_t] should be non-null. *)
272
272
273
273
let _ = id_non_null_value (lazy 3 )
274
274
;;
Original file line number Diff line number Diff line change @@ -148,9 +148,10 @@ val any : why:any_creation_reason -> t
148
148
(* * Value of types of this jkind are not retained at all at runtime *)
149
149
val void : why :void_creation_reason -> t
150
150
151
- (* * This is the jkind of normal ocaml values *)
151
+ (* * This is the jkind of normal ocaml values and null pointers. *)
152
152
val value : why :value_creation_reason -> t
153
153
154
+ (* * This is the jkind of normal ocaml values. They have sort Value. *)
154
155
val non_null_value : why :non_null_value_creation_reason -> t
155
156
156
157
(* * Values of types of this jkind are immediate on 64-bit platforms; on other
You can’t perform that action at this time.
0 commit comments