Skip to content

Commit 3c4d222

Browse files
authored
Remove a check for values in with type constraints (#2338)
* Add test * Fix one bug, but blocked by the package hack * Remove now-redundant comment
1 parent ff28a6f commit 3c4d222

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

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

+27
Original file line numberDiff line numberDiff line change
@@ -716,3 +716,30 @@ Error: Function arguments and returns must be representable.
716716
it's the type of a function argument.
717717
|}]
718718

719+
(***********************************)
720+
(* Test 11: [any] in package types *)
721+
722+
module type S = sig
723+
type t : any
724+
end
725+
726+
module C : S = struct
727+
type t = float
728+
end
729+
730+
let x = (module C : S with type t = 'a)
731+
732+
(* This should be accepted *)
733+
[%%expect{|
734+
module type S = sig type t : any end
735+
module C : S
736+
Line 9, characters 8-39:
737+
9 | let x = (module C : S with type t = 'a)
738+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
739+
Error: This expression has type (module S with type t = C.t)
740+
but an expression was expected of type (module S with type t = 'a)
741+
The layout of C.t is any, because
742+
of the definition of t at line 2, characters 2-14.
743+
But the layout of C.t must be a sublayout of value, because
744+
it's a type declaration in a first-class module.
745+
|}]

ocaml/typing/typemod.ml

+1-2
Original file line numberDiff line numberDiff line change
@@ -3272,9 +3272,8 @@ let type_package env m p fl =
32723272
in
32733273
List.iter
32743274
(fun (n, ty) ->
3275-
(* CR layouts v5: relax value requirement. *)
32763275
try Ctype.unify env ty
3277-
(Ctype.newvar (Jkind.value ~why:Structure_element))
3276+
(Ctype.newvar (Jkind.any ~why:Dummy_jkind))
32783277
with Ctype.Unify _ ->
32793278
raise (Error(modl.mod_loc, env, Scoping_pack (n,ty))))
32803279
fl';

0 commit comments

Comments
 (0)