Skip to content

Remove duplicated creation_reasons from layout history error messages #1825

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 9 commits into from
Sep 18, 2023
86 changes: 30 additions & 56 deletions ocaml/testsuite/tests/typing-layouts-float64/basics_alpha.ml
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,8 @@ Line 1, characters 27-29:
Error: This type ('a : value) should be an instance of type ('a0 : float64)
The layout of 'a is float64, because
of the annotation on 'a in the declaration of the type t4_6.
But the layout of 'a must overlap with value, because all of the following:
a tuple element
a tuple element
But the layout of 'a must overlap with value, because
a tuple element.
|}];;

(* check for layout propagation *)
Expand All @@ -191,11 +190,8 @@ Line 1, characters 32-34:
Error: This type ('b : value) should be an instance of type ('a : float64)
The layout of 'a is float64, because
of the annotation on 'a in the declaration of the type t4_7.
But the layout of 'a must overlap with value, because all of the following:
used as a function argument
a tuple element
a tuple element
appears as an unannotated type parameter
But the layout of 'a must overlap with value, because
a tuple element.
|}]

(****************************************************)
Expand Down Expand Up @@ -414,10 +410,8 @@ Error: This expression has type t_float64
but an expression was expected of type ('a : value)
The layout of t_float64 is float64, because
of the annotation on the declaration of the type t_float64.
But the layout of t_float64 must be a sublayout of value, because all of the following:
used as a function argument
used as a function argument
used as a function result
But the layout of t_float64 must be a sublayout of value, because
used as a function result.
|}];;

let x8_2 = id_value (make_t_float64_id ());;
Expand All @@ -429,10 +423,8 @@ Error: This expression has type 'a t_float64_id = ('a : float64)
but an expression was expected of type ('b : value)
The layout of 'a t_float64_id is float64, because
of the annotation on 'a in the declaration of the type t_float64_id.
But the layout of 'a t_float64_id must overlap with value, because all of the following:
used as a function argument
used as a function argument
used as a function result
But the layout of 'a t_float64_id must overlap with value, because
used as a function result.
|}];;

let x8_3 = id_value (make_floatu ());;
Expand All @@ -444,10 +436,8 @@ Error: This expression has type float# but an expression was expected of type
('a : value)
The layout of float# is float64, because
it equals the primitive value type float#.
But the layout of float# must be a sublayout of value, because all of the following:
used as a function argument
used as a function argument
used as a function result
But the layout of float# must be a sublayout of value, because
used as a function result.
|}];;

(*************************************)
Expand Down Expand Up @@ -640,14 +630,10 @@ Line 2, characters 13-15:
2 | method x : 'a t_float64_id -> 'a t_float64_id = assert false
^^
Error: This type ('a : float64) should be an instance of type ('a0 : value)
The layout of 'a is value, because all of the following:
appears as an unannotated type parameter
a term-level argument to a class constructor
But the layout of 'a must overlap with float64, because all of the following:
of the annotation on 'a in the declaration of the type
t_float64_id
of the annotation on 'a in the declaration of the type
t_float64_id
The layout of 'a is value, because
a term-level argument to a class constructor.
But the layout of 'a must overlap with float64, because
of the annotation on 'a in the declaration of the type t_float64_id.
|}];;
(* CR layouts v2.9: Error could be improved *)

Expand All @@ -672,9 +658,8 @@ Line 1, characters 26-43:
Error: The method x has type float# but is expected to have type ('a : value)
The layout of float# is float64, because
it equals the primitive value type float#.
But the layout of float# must be a sublayout of value, because all of the following:
an object field
an object field
But the layout of float# must be a sublayout of value, because
an object field.
|}];;
(* CR layouts v2.9: Error could be improved *)

Expand All @@ -699,14 +684,10 @@ Line 2, characters 10-12:
2 | val x : 'a t_float64_id -> 'a t_float64_id
^^
Error: This type ('a : float64) should be an instance of type ('a0 : value)
The layout of 'a is value, because all of the following:
appears as an unannotated type parameter
a term-level argument to a class constructor
But the layout of 'a must overlap with float64, because all of the following:
of the annotation on 'a in the declaration of the type
t_float64_id
of the annotation on 'a in the declaration of the type
t_float64_id
The layout of 'a is value, because
a term-level argument to a class constructor.
But the layout of 'a must overlap with float64, because
of the annotation on 'a in the declaration of the type t_float64_id.
|}];;

(* Second, allowed uses: as method parameters / returns *)
Expand Down Expand Up @@ -744,9 +725,8 @@ Error: This expression has type ('a : value)
but an expression was expected of type t_float64
The layout of t_float64 is float64, because
of the annotation on the declaration of the type t_float64.
But the layout of t_float64 must be a sublayout of value, because all of the following:
captured in an object
used as a function argument
But the layout of t_float64 must be a sublayout of value, because
captured in an object.
|}];;

let f12_14 (m1 : t_float64) (m2 : t_float64) = object
Expand Down Expand Up @@ -782,10 +762,8 @@ Error: This expression has type t_float64
but an expression was expected of type ('a : value)
The layout of t_float64 is float64, because
of the annotation on the declaration of the type t_float64.
But the layout of t_float64 must be a sublayout of value, because all of the following:
used as a function argument
used as a function argument
imported from another compilation unit
But the layout of t_float64 must be a sublayout of value, because
imported from another compilation unit.
|}];;

let f13_2 (x : t_float64) = compare x x;;
Expand All @@ -797,10 +775,8 @@ Error: This expression has type t_float64
but an expression was expected of type ('a : value)
The layout of t_float64 is float64, because
of the annotation on the declaration of the type t_float64.
But the layout of t_float64 must be a sublayout of value, because all of the following:
used as a function argument
used as a function argument
imported from another compilation unit
But the layout of t_float64 must be a sublayout of value, because
imported from another compilation unit.
|}];;

let f13_3 (x : t_float64) = Marshal.to_bytes x;;
Expand All @@ -812,9 +788,8 @@ Error: This expression has type t_float64
but an expression was expected of type ('a : value)
The layout of t_float64 is float64, because
of the annotation on the declaration of the type t_float64.
But the layout of t_float64 must be a sublayout of value, because all of the following:
used as a function argument
imported from another compilation unit
But the layout of t_float64 must be a sublayout of value, because
imported from another compilation unit.
|}];;

let f13_4 (x : t_float64) = Hashtbl.hash x;;
Expand All @@ -826,7 +801,6 @@ Error: This expression has type t_float64
but an expression was expected of type ('a : value)
The layout of t_float64 is float64, because
of the annotation on the declaration of the type t_float64.
But the layout of t_float64 must be a sublayout of value, because all of the following:
used as a function argument
imported from another compilation unit
But the layout of t_float64 must be a sublayout of value, because
imported from another compilation unit.
|}];;
80 changes: 16 additions & 64 deletions ocaml/testsuite/tests/typing-layouts-float64/parsing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,8 @@ Line 1, characters 9-15:
Error: This type float# should be an instance of type ('a : value)
The layout of float# is float64, because
it equals the primitive value type float#.
But the layout of float# must be a sublayout of value, because all of the following:
a type argument defaulted to have layout value
a type argument defaulted to have layout value
used as a function result
an object
an object field
appears as an unannotated type parameter
a term-level argument to a class constructor
But the layout of float# must be a sublayout of value, because
a term-level argument to a class constructor.
|}];;

let f (_ : float#c) = ();;
Expand All @@ -122,14 +116,8 @@ Line 1, characters 11-17:
Error: This type float# should be an instance of type ('a : value)
The layout of float# is float64, because
it equals the primitive value type float#.
But the layout of float# must be a sublayout of value, because all of the following:
a type argument defaulted to have layout value
a type argument defaulted to have layout value
used as a function result
an object
an object field
appears as an unannotated type parameter
a term-level argument to a class constructor
But the layout of float# must be a sublayout of value, because
a term-level argument to a class constructor.
|}];;

type t = C of float#c;;
Expand All @@ -140,14 +128,8 @@ Line 1, characters 14-20:
Error: This type float# should be an instance of type ('a : value)
The layout of float# is float64, because
it equals the primitive value type float#.
But the layout of float# must be a sublayout of value, because all of the following:
a type argument defaulted to have layout value
a type argument defaulted to have layout value
used as a function result
an object
an object field
appears as an unannotated type parameter
a term-level argument to a class constructor
But the layout of float# must be a sublayout of value, because
a term-level argument to a class constructor.
|}];;

type t = C : float#c -> t;;
Expand All @@ -158,14 +140,8 @@ Line 1, characters 13-19:
Error: This type float# should be an instance of type ('a : value)
The layout of float# is float64, because
it equals the primitive value type float#.
But the layout of float# must be a sublayout of value, because all of the following:
a type argument defaulted to have layout value
a type argument defaulted to have layout value
used as a function result
an object
an object field
appears as an unannotated type parameter
a term-level argument to a class constructor
But the layout of float# must be a sublayout of value, because
a term-level argument to a class constructor.
|}];;

(* Syntax: float# c
Expand All @@ -179,14 +155,8 @@ Line 1, characters 9-15:
Error: This type float# should be an instance of type ('a : value)
The layout of float# is float64, because
it equals the primitive value type float#.
But the layout of float# must be a sublayout of value, because all of the following:
a type argument defaulted to have layout value
a type argument defaulted to have layout value
used as a function result
an object
an object field
appears as an unannotated type parameter
a term-level argument to a class constructor
But the layout of float# must be a sublayout of value, because
a term-level argument to a class constructor.
|}];;

let f (_ : float# c) = ();;
Expand All @@ -197,14 +167,8 @@ Line 1, characters 11-17:
Error: This type float# should be an instance of type ('a : value)
The layout of float# is float64, because
it equals the primitive value type float#.
But the layout of float# must be a sublayout of value, because all of the following:
a type argument defaulted to have layout value
a type argument defaulted to have layout value
used as a function result
an object
an object field
appears as an unannotated type parameter
a term-level argument to a class constructor
But the layout of float# must be a sublayout of value, because
a term-level argument to a class constructor.
|}];;

type t = C of float# c;;
Expand All @@ -215,14 +179,8 @@ Line 1, characters 14-20:
Error: This type float# should be an instance of type ('a : value)
The layout of float# is float64, because
it equals the primitive value type float#.
But the layout of float# must be a sublayout of value, because all of the following:
a type argument defaulted to have layout value
a type argument defaulted to have layout value
used as a function result
an object
an object field
appears as an unannotated type parameter
a term-level argument to a class constructor
But the layout of float# must be a sublayout of value, because
a term-level argument to a class constructor.
|}];;

type t = C : float# c -> t;;
Expand All @@ -233,14 +191,8 @@ Line 1, characters 13-19:
Error: This type float# should be an instance of type ('a : value)
The layout of float# is float64, because
it equals the primitive value type float#.
But the layout of float# must be a sublayout of value, because all of the following:
a type argument defaulted to have layout value
a type argument defaulted to have layout value
used as a function result
an object
an object field
appears as an unannotated type parameter
a term-level argument to a class constructor
But the layout of float# must be a sublayout of value, because
a term-level argument to a class constructor.
|}];;

(* Syntax: float #c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ Error: This expression has type t_void -> unit
but an expression was expected of type 'a -> unit
The layout of t_void is void, because
of the annotation on the declaration of the type t_void.
But the layout of t_void must be a sublayout of value, because all of the following:
used as a function result
imported from another compilation unit
But the layout of t_void must be a sublayout of value, because
imported from another compilation unit.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ Error: This expression has type t_void -> unit
but an expression was expected of type 'a -> unit
The layout of t_void is void, because
of the annotation on the declaration of the type t_void.
But the layout of t_void must be a sublayout of value, because all of the following:
used as a function result
imported from another compilation unit
But the layout of t_void must be a sublayout of value, because
imported from another compilation unit.
18 changes: 6 additions & 12 deletions ocaml/testsuite/tests/typing-layouts/annots_beta.ml
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,8 @@ Line 2, characters 18-55:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This field value has type 'b -> 'b which is less general than
'a. 'a -> 'a
The layout of 'a is value, because all of the following:
used as a function result
used as a function argument
an unannotated universal variable
The layout of 'a is value, because
an unannotated universal variable.
But the layout of 'a must be a sublayout of immediate, because
of the annotation on the abstract type declaration for a.
|}]
Expand All @@ -279,10 +277,8 @@ type ('a : immediate) t_imm
Line 3, characters 15-39:
3 | type s = { f : ('a : value). 'a -> 'a u }
^^^^^^^^^^^^^^^^^^^^^^^^
Error: The layout of Type 'a is value, because all of the following:
used as a function argument
appears as an unannotated type parameter
of the annotation on the universal variable a
Error: The layout of Type 'a is value, because
of the annotation on the universal variable a.
But the layout of Type 'a must be a sublayout of immediate, because
of the annotation on 'a in the declaration of the type t_imm.

Expand Down Expand Up @@ -518,10 +514,8 @@ Line 1, characters 37-53:
^^^^^^^^^^^^^^^^
Error: This definition has type 'b -> 'b which is less general than
'a. 'a -> 'a
The layout of 'a is value, because all of the following:
used as a function result
used as a function argument
of the annotation on the universal variable a
The layout of 'a is value, because
of the annotation on the universal variable a.
But the layout of 'a must be a sublayout of immediate, because
of the annotation on the universal variable a.
|}]
Expand Down
Loading