Skip to content

Commit eaa9412

Browse files
committed
Add additional test
1 parent 3053a98 commit eaa9412

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

ocaml/testsuite/tests/typing-modules/package_constraint.ml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,28 @@ module F :
220220
functor (X : sig val x : m end) ->
221221
sig module M : sig type t = int end type t = M.t end
222222
|}];;
223+
224+
(* In cases where the package constraint involves a type variable from the
225+
current ty var env, it can affect inference. t1 below should check but not
226+
t2. *)
227+
module type S = sig
228+
type t : immediate
229+
end
230+
231+
type 'a t = (module S with type t = 'a)
232+
233+
type t1 = int t
234+
type t2 = string t
235+
[%%expect{|
236+
module type S = sig type t : immediate end
237+
type ('a : immediate) t = (module S with type t = 'a)
238+
type t1 = int t
239+
Line 8, characters 10-16:
240+
8 | type t2 = string t
241+
^^^^^^
242+
Error: This type string should be an instance of type ('a : immediate)
243+
The layout of string is value, because
244+
it is the primitive value type string.
245+
But the layout of string must be a sublayout of immediate, because
246+
of the definition of t at line 5, characters 0-39.
247+
|}];;

0 commit comments

Comments
 (0)