Skip to content

Fix the package hack #2253

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

Merged
merged 7 commits into from
Mar 7, 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
25 changes: 0 additions & 25 deletions ocaml/testsuite/tests/typing-layouts-err-msg/value.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,6 @@ Error: Tuple element types must have layout value.
(* Probe *)
(* See [probe.ml] *)

(* Package_hack *)
module type S = sig
type t : immediate
end

module type S2 = sig
val m : (module S with type t = string)
end
[%%expect{|
module type S = sig type t : immediate end
Line 6, characters 10-41:
6 | val m : (module S with type t = string)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t
is not included in
type t : immediate
The layout of the first is value, because
it's a type declaration in a first-class module.
But the layout of the first must be a sublayout of immediate, because
of the definition of t at line 2, characters 2-20.
|}];;

(* Object *)
let f: ('a : void) -> 'b = fun x -> x # baz
[%%expect{|
Expand Down
16 changes: 4 additions & 12 deletions ocaml/testsuite/tests/typing-layouts/erasable_annot.ml
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,11 @@ end

[%%expect {|
module type S = sig type t : immediate64 end
Line 6, characters 16-43:
Line 6, characters 2-49:
6 | val f : 'a -> (module S with type t = 'a) -> 'a
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t
is not included in
type t : immediate64
The layout of the first is value, because
it's a type declaration in a first-class module.
But the layout of the first must be a sublayout of immediate64, because
of the definition of t at line 2, characters 2-23.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Usage of layout immediate/immediate64 in f can't be erased.
This error is produced due to the use of -only-erasable-extensions.
|}];;

(* Annotations here do nothing and should be accepted *)
Expand Down
58 changes: 21 additions & 37 deletions ocaml/testsuite/tests/typing-layouts/modules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,11 @@ Line 6, characters 10-42:
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t
type t = int
is not included in
type t : float64
The layout of the first is value, because
it's a type declaration in a first-class module.
The layout of the first is immediate, because
it is the primitive immediate type int.
But the layout of the first must be a sublayout of float64, because
of the definition of t at line 2, characters 2-18.
|}];;
Expand All @@ -516,14 +516,19 @@ module type S6_4f = sig
end;;
[%%expect{|
module type S6_3 = sig type t : value end
Line 6, characters 33-34:
Line 6, characters 10-47:
6 | val m : (module S6_3 with type t = t_float64)
^
Error: Signature package constraint types must have layout value.
The layout of t_float64 is float64, because
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t = t_float64
is not included in
type t : value
The layout of the first is float64, because
of the definition of t_float64 at line 4, characters 0-24.
But the layout of t_float64 must be a sublayout of value, because
it's a type declaration in a first-class module.
But the layout of the first must be a sublayout of value, because
of the definition of t at line 2, characters 2-16.
|}];;

module type S6_5 = sig
Expand All @@ -541,11 +546,11 @@ Line 6, characters 10-44:
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t
type t = string
is not included in
type t : immediate
The layout of the first is value, because
it's a type declaration in a first-class module.
it is the primitive value type string.
But the layout of the first must be a sublayout of immediate, because
of the definition of t at line 2, characters 2-20.
|}];;
Expand All @@ -561,34 +566,22 @@ Line 3, characters 10-39:
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t
type t = s
is not included in
type t : immediate
The layout of the first is value, because
it's a type declaration in a first-class module.
of the definition of s at line 2, characters 2-8.
But the layout of the first must be a sublayout of immediate, because
of the definition of t at line 2, characters 2-20.
|}];;

(* CR layouts: S6_6'' should be fixed *)
module type S6_6'' = sig
type s = int
val m : (module S6_5 with type t = int)
end;;
[%%expect{|
Line 3, characters 10-41:
3 | val m : (module S6_5 with type t = int)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t
is not included in
type t : immediate
The layout of the first is value, because
it's a type declaration in a first-class module.
But the layout of the first must be a sublayout of immediate, because
of the definition of t at line 2, characters 2-20.
module type S6_6'' =
sig type s = int val m : (module S6_5 with type t = int) end
|}];;

(*****************************************)
Expand Down Expand Up @@ -729,17 +722,8 @@ 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.
val x : (module S with type t = C.t) = <module>
|}]
47 changes: 20 additions & 27 deletions ocaml/testsuite/tests/typing-layouts/modules_alpha.ml
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,11 @@ Line 6, characters 10-41:
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t
type t = int
is not included in
type t : void
The layout of the first is value, because
it's a type declaration in a first-class module.
The layout of the first is immediate, because
it is the primitive immediate type int.
But the layout of the first must be a sublayout of void, because
of the definition of t at line 2, characters 2-15.
|}];;
Expand All @@ -433,14 +433,19 @@ module type S6_4 = sig
end;;
[%%expect{|
module type S6_3 = sig type t : value end
Line 6, characters 33-34:
Line 6, characters 10-44:
6 | val m : (module S6_3 with type t = t_void)
^
Error: Signature package constraint types must have layout value.
The layout of t_void is void, because
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t = t_void
is not included in
type t : value
The layout of the first is void, because
of the definition of t_void at line 5, characters 0-19.
But the layout of t_void must be a sublayout of value, because
it's a type declaration in a first-class module.
But the layout of the first must be a sublayout of value, because
of the definition of t at line 2, characters 2-16.
|}];;

module type S6_5 = sig
Expand All @@ -458,11 +463,11 @@ Line 6, characters 10-44:
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t
type t = string
is not included in
type t : immediate
The layout of the first is value, because
it's a type declaration in a first-class module.
it is the primitive value type string.
But the layout of the first must be a sublayout of immediate, because
of the definition of t at line 2, characters 2-20.
|}];;
Expand All @@ -478,34 +483,22 @@ Line 3, characters 10-39:
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t
type t = s
is not included in
type t : immediate
The layout of the first is value, because
it's a type declaration in a first-class module.
of the definition of s at line 2, characters 2-8.
But the layout of the first must be a sublayout of immediate, because
of the definition of t at line 2, characters 2-20.
|}];;

(* CR layouts: S6_6'' should be fixed *)
module type S6_6'' = sig
type s = int
val m : (module S6_5 with type t = int)
end;;
[%%expect{|
Line 3, characters 10-41:
3 | val m : (module S6_5 with type t = int)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t
is not included in
type t : immediate
The layout of the first is value, because
it's a type declaration in a first-class module.
But the layout of the first must be a sublayout of immediate, because
of the definition of t at line 2, characters 2-20.
module type S6_6'' =
sig type s = int val m : (module S6_5 with type t = int) end
|}];;

(*****************************************)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ File "pr6293_bad.ml", line 10, characters 18-37:
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t
type t = int
is not included in
type t = { a : int; b : int; }
The first is abstract, but the second is a record.
Expand Down
Loading