Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove a check for values in with type constraints #2338

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions ocaml/testsuite/tests/typing-layouts/modules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -716,3 +716,30 @@ Error: Function arguments and returns must be representable.
it's the type of a function argument.
|}]

(***********************************)
(* Test 11: [any] in package types *)

module type S = sig
type t : any
end

module C : S = struct
type t = float
end

let x = (module C : S with type t = 'a)

(* This should be accepted *)
[%%expect{|
module type S = sig type t : any end
module C : S
Line 9, characters 8-39:
9 | let x = (module C : S with type t = 'a)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This expression has type (module S with type t = C.t)
but an expression was expected of type (module S with type t = 'a)
The layout of C.t is any, because
of the definition of t at line 2, characters 2-14.
But the layout of C.t must be a sublayout of value, because
it's a type declaration in a first-class module.
|}]
3 changes: 1 addition & 2 deletions ocaml/typing/typemod.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3272,9 +3272,8 @@ let type_package env m p fl =
in
List.iter
(fun (n, ty) ->
(* CR layouts v5: relax value requirement. *)
try Ctype.unify env ty
(Ctype.newvar (Jkind.value ~why:Structure_element))
(Ctype.newvar (Jkind.any ~why:Dummy_jkind))
with Ctype.Unify _ ->
raise (Error(modl.mod_loc, env, Scoping_pack (n,ty))))
fl';
Expand Down
Loading