Skip to content

Commit 64167a4

Browse files
authored
flambda-backend: Jkind Error Messages (#2730)
* Fix Jkind.format * Improve error messages * Improve more error messages * Promote failing tests * Improve formatting * Format jkind.ml * Undo because shuffling in tests * Undo layout->kind rename in tests * Undo removing legacy layouts in tests * Move print_out_jkind to oprint * Fix build issues * Fix more build issues * Make tests say kind when appropriate, and print actual layouts instead of legacy * Update tests to shuffle because * Promote failing jkinds and allow_illegal_crossing tests * Create locale type
1 parent 8e96af6 commit 64167a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3288
-3357
lines changed

compilerlibs/Makefile.compilerlibs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ TYPING = \
9191
typing/shape.cmo \
9292
typing/zero_alloc.cmo \
9393
typing/types.cmo \
94-
typing/jkind.cmo \
9594
typing/btype.cmo \
9695
typing/oprint.cmo \
96+
typing/jkind.cmo \
9797
typing/subst.cmo \
9898
typing/predef.cmo \
9999
typing/datarepr.cmo \

otherlibs/dynlink/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ COMPILERLIBS_SOURCES=\
123123
typing/primitive.ml \
124124
typing/zero_alloc.ml \
125125
typing/types.ml \
126+
typing/oprint.ml \
126127
typing/jkind.ml \
127128
typing/typedtree.ml \
128129
typing/btype.ml \

otherlibs/dynlink/dune

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
primitive
9797
zero_alloc
9898
types
99+
oprint
99100
jkind
100101
value_rec_types
101102
btype
@@ -194,6 +195,7 @@
194195
(copy_files ../../typing/jkind.ml)
195196
(copy_files ../../typing/jkind_intf.ml)
196197
(copy_files ../../typing/jkind_types.ml)
198+
(copy_files ../../typing/oprint.ml)
197199
(copy_files ../../typing/primitive.ml)
198200
(copy_files ../../typing/shape.ml)
199201
(copy_files ../../typing/solver.ml)
@@ -264,6 +266,7 @@
264266
(copy_files ../../typing/jkind.mli)
265267
(copy_files ../../typing/jkind_intf.mli)
266268
(copy_files ../../typing/jkind_types.mli)
269+
(copy_files ../../typing/oprint.mli)
267270
(copy_files ../../typing/primitive.mli)
268271
(copy_files ../../typing/shape.mli)
269272
(copy_files ../../typing/solver.mli)
@@ -386,6 +389,7 @@
386389
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Types.cmo
387390
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Attr_helper.cmo
388391
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Primitive.cmo
392+
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Oprint.cmo
389393
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Jkind.cmo
390394
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Btype.cmo
391395
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Subst.cmo
@@ -470,6 +474,7 @@
470474
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Types.cmx
471475
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Attr_helper.cmx
472476
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Primitive.cmx
477+
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Oprint.cmx
473478
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Jkind.cmx
474479
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Btype.cmx
475480
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Subst.cmx

testsuite/tests/hidden_includes/missing_cmi_layout.ocamlc.reference

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ File "libc/c2.ml", line 1, characters 12-15:
22
1 | let x = B.f B.x
33
^^^
44
Error: Function arguments and returns must be representable.
5-
The layout of A.t is any, because
6-
the .cmi file for A.t is missing.
7-
But the layout of A.t must be representable, because
8-
we must know concretely how to pass a function argument.
5+
The layout of A.t is any
6+
because the .cmi file for A.t is missing.
7+
But the layout of A.t must be representable
8+
because we must know concretely how to pass a function argument.
99
No .cmi file found containing A.t.
1010
Hint: Adding "a" to your dependencies might help.

testsuite/tests/typing-immediate/immediate.ml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ end;;
143143
Line 2, characters 2-31:
144144
2 | type t = string [@@immediate]
145145
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
146-
Error: The layout of type string is value, because
147-
it is the primitive value type string.
148-
But the layout of type string must be a sublayout of immediate, because
149-
of the definition of t at line 2, characters 2-31.
146+
Error: The kind of type string is value
147+
because it is the primitive value type string.
148+
But the kind of type string must be a subkind of immediate
149+
because of the definition of t at line 2, characters 2-31.
150150
|}];;
151151
(* CR layouts v2.9: The "of the definition of t ..." part is not great and it
152152
should only refer to definitions that type check. Fixing it will involve
@@ -160,10 +160,10 @@ end;;
160160
Line 2, characters 2-41:
161161
2 | type t = Foo of int | Bar [@@immediate]
162162
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
163-
Error: The layout of type t is value, because
164-
it's a boxed variant type.
165-
But the layout of type t must be a sublayout of immediate, because
166-
of the annotation on the declaration of the type t.
163+
Error: The kind of type t is value
164+
because it's a boxed variant type.
165+
But the kind of type t must be a subkind of immediate
166+
because of the annotation on the declaration of the type t.
167167
|}];;
168168

169169
(* Cannot directly declare a non-immediate type as immediate (record) *)
@@ -174,10 +174,10 @@ end;;
174174
Line 2, characters 2-38:
175175
2 | type t = { foo : int } [@@immediate]
176176
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
177-
Error: The layout of type t is value, because
178-
it's a boxed record type.
179-
But the layout of type t must be a sublayout of immediate, because
180-
of the annotation on the declaration of the type t.
177+
Error: The kind of type t is value
178+
because it's a boxed record type.
179+
But the kind of type t must be a subkind of immediate
180+
because of the annotation on the declaration of the type t.
181181
|}];;
182182

183183
(* Not guaranteed that t is immediate, so this is an invalid declaration *)
@@ -189,10 +189,10 @@ end;;
189189
Line 3, characters 2-26:
190190
3 | type s = t [@@immediate]
191191
^^^^^^^^^^^^^^^^^^^^^^^^
192-
Error: The layout of type t is value, because
193-
of the definition of t at line 2, characters 2-8.
194-
But the layout of type t must be a sublayout of immediate, because
195-
of the definition of s at line 3, characters 2-26.
192+
Error: The kind of type t is value
193+
because of the definition of t at line 2, characters 2-8.
194+
But the kind of type t must be a subkind of immediate
195+
because of the definition of s at line 3, characters 2-26.
196196
|}];;
197197

198198
(* Can't ascribe to an immediate type signature with a non-immediate type *)
@@ -213,10 +213,10 @@ Error: Signature mismatch:
213213
type t = string
214214
is not included in
215215
type t : immediate
216-
The layout of the first is value, because
217-
it is the primitive value type string.
218-
But the layout of the first must be a sublayout of immediate, because
219-
of the definition of t at line 1, characters 15-35.
216+
The kind of the first is value
217+
because it is the primitive value type string.
218+
But the kind of the first must be a subkind of immediate
219+
because of the definition of t at line 1, characters 15-35.
220220
|}];;
221221

222222
(* Same as above but with explicit signature *)
@@ -231,10 +231,10 @@ Error: Signature mismatch:
231231
type t = string
232232
is not included in
233233
type t : immediate
234-
The layout of the first is value, because
235-
it is the primitive value type string.
236-
But the layout of the first must be a sublayout of immediate, because
237-
of the definition of t at line 1, characters 20-40.
234+
The kind of the first is value
235+
because it is the primitive value type string.
236+
But the kind of the first must be a subkind of immediate
237+
because of the definition of t at line 1, characters 20-40.
238238
|}];;
239239

240240
module FM_invalid = F (struct type t = string end);;
@@ -248,10 +248,10 @@ Error: Modules do not match: sig type t = string end is not included in
248248
type t = string
249249
is not included in
250250
type t : immediate
251-
The layout of the first is value, because
252-
it is the primitive value type string.
253-
But the layout of the first must be a sublayout of immediate, because
254-
of the definition of t at line 1, characters 20-40.
251+
The kind of the first is value
252+
because it is the primitive value type string.
253+
But the kind of the first must be a subkind of immediate
254+
because of the definition of t at line 1, characters 20-40.
255255
|}];;
256256

257257
(* Can't use a non-immediate type even if mutually recursive *)
@@ -263,10 +263,10 @@ end;;
263263
Line 2, characters 2-26:
264264
2 | type t = s [@@immediate]
265265
^^^^^^^^^^^^^^^^^^^^^^^^
266-
Error: The layout of type s is value, because
267-
it is the primitive value type string.
268-
But the layout of type s must be a sublayout of immediate, because
269-
of the definition of t at line 2, characters 2-26.
266+
Error: The kind of type s is value
267+
because it is the primitive value type string.
268+
But the kind of type s must be a subkind of immediate
269+
because of the definition of t at line 2, characters 2-26.
270270
|}];;
271271

272272

testsuite/tests/typing-layouts-arrays/basics.ml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ Line 1, characters 27-28:
9191
^
9292
Error: This expression has type float# array
9393
but an expression was expected of type 'a array
94-
The layout of float# is float64, because
95-
it is the primitive float64 type float#.
96-
But the layout of float# must be a sublayout of value, because
97-
of layout requirements from an imported definition.
94+
The layout of float# is float64
95+
because it is the primitive float64 type float#.
96+
But the layout of float# must be a sublayout of value
97+
because of layout requirements from an imported definition.
9898
|}];;
9999

100100
let f (x : float# array) = Array.length x
@@ -104,10 +104,10 @@ Line 1, characters 40-41:
104104
^
105105
Error: This expression has type float# array
106106
but an expression was expected of type 'a array
107-
The layout of float# is float64, because
108-
it is the primitive float64 type float#.
109-
But the layout of float# must be a sublayout of value, because
110-
of layout requirements from an imported definition.
107+
The layout of float# is float64
108+
because it is the primitive float64 type float#.
109+
But the layout of float# must be a sublayout of value
110+
because of layout requirements from an imported definition.
111111
|}];;
112112

113113
(*****************************************************************)
@@ -144,10 +144,10 @@ Line 2, characters 23-30:
144144
2 | let d (x : 'a array) = get x 0
145145
^^^^^^^
146146
Error: A representable layout is required here.
147-
The layout of 'a is any, because
148-
of the definition of d at line 2, characters 6-30.
149-
But the layout of 'a must be representable, because
150-
it's the type of an array element.
147+
The layout of 'a is any
148+
because of the definition of d at line 2, characters 6-30.
149+
But the layout of 'a must be representable
150+
because it's the type of an array element.
151151
|}];;
152152

153153
external get : int32# array -> int -> float = "%floatarray_safe_get"
@@ -257,10 +257,10 @@ Line 11, characters 79-82:
257257
^^^
258258
Error: This expression has type int64# but an expression was expected of type
259259
('a : bits32)
260-
The layout of int64# is bits64, because
261-
it is the primitive bits64 type int64#.
262-
But the layout of int64# must be a sublayout of bits32, because
263-
of the definition of get_third at lines 4-7, characters 16-23.
260+
The layout of int64# is bits64
261+
because it is the primitive bits64 type int64#.
262+
But the layout of int64# must be a sublayout of bits32
263+
because of the definition of get_third at lines 4-7, characters 16-23.
264264
|}]
265265

266266
module M6_2 = struct
@@ -282,10 +282,10 @@ Line 9, characters 24-35:
282282
^^^^^^^^^^^
283283
Error: This expression has type ('a : float64)
284284
but an expression was expected of type int32#
285-
The layout of int32# is bits32, because
286-
it is the primitive bits32 type int32#.
287-
But the layout of int32# must be a sublayout of float64, because
288-
of the definition of arr at line 6, characters 12-16.
285+
The layout of int32# is bits32
286+
because it is the primitive bits32 type int32#.
287+
But the layout of int32# must be a sublayout of float64
288+
because of the definition of arr at line 6, characters 12-16.
289289
|}]
290290

291291
(*********************)

testsuite/tests/typing-layouts-arrays/exp_and_pat_failing.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ Line 25, characters 13-29:
5252
^^^^^^^^^^^^^^^^
5353
Error: This expression has type Float_u.t = float#
5454
but an expression was expected of type ('a : value)
55-
The layout of Float_u.t is float64, because
56-
it is the primitive float64 type float#.
57-
But the layout of Float_u.t must be a sublayout of value, because
58-
it's the element type of array comprehension.
55+
The layout of Float_u.t is float64
56+
because it is the primitive float64 type float#.
57+
But the layout of Float_u.t must be a sublayout of value
58+
because it's the element type of array comprehension.
5959
|}];;

0 commit comments

Comments
 (0)