Skip to content

Commit c6278ce

Browse files
committed
force message to be on new line
1 parent 3630621 commit c6278ce

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Line 1, characters 28-44:
166166
1 | let f (x : bool) = (x : int)[@error_message]
167167
^^^^^^^^^^^^^^^^
168168
Warning 47 [attribute-payload]: illegal payload for attribute 'error_message'.
169-
Error_message attribute expects a string argument
169+
error_message attribute expects a string argument
170170
Line 1, characters 20-21:
171171
1 | let f (x : bool) = (x : int)[@error_message]
172172
^
@@ -177,16 +177,12 @@ Error: This expression has type bool but an expression was expected of type
177177
(* Can only be applied once *)
178178
let f (x : bool) = (x : int)[@error_message "A"][@error_message "B"]
179179
[%%expect{|
180-
Line 1, characters 48-68:
181-
1 | let f (x : bool) = (x : int)[@error_message "A"][@error_message "B"]
182-
^^^^^^^^^^^^^^^^^^^^
183-
Warning 47 [attribute-payload]: illegal payload for attribute 'error_message'.
184-
More than one error_message attribute present. All of them will be ignored.
185180
Line 1, characters 20-21:
186181
1 | let f (x : bool) = (x : int)[@error_message "A"][@error_message "B"]
187182
^
188183
Error: This expression has type bool but an expression was expected of type
189184
int
185+
A
190186
|}]
191187

192188
(* Simple test case *)
@@ -197,7 +193,7 @@ Line 1, characters 20-21:
197193
^
198194
Error: This expression has type bool but an expression was expected of type
199195
int
200-
because [@error_message]: custom message
196+
custom message
201197
|}]
202198

203199
(* Doesn't work when the type mismatch happens later. This differ from
@@ -231,7 +227,7 @@ Line 1, characters 22-23:
231227
^
232228
Error: This expression has type string but an expression was expected of type
233229
('a : immediate)
234-
because [@error_message]: custom message
230+
custom message
235231
The layout of string is value, because
236232
it is the primitive value type string.
237233
But the layout of string must be a sublayout of immediate, because
@@ -254,7 +250,8 @@ Line 1, characters 12-29:
254250
1 | let f () = (fun (x: int) -> x : string)[@error_message "custom message"]
255251
^^^^^^^^^^^^^^^^^
256252
Error: This expression should not be a function, the expected type is
257-
string because [@error_message]: custom message
253+
string
254+
custom message
258255
|}]
259256

260257
(* Same when the function is not declared inline *)
@@ -279,5 +276,5 @@ Line 2, characters 12-13:
279276
^
280277
Error: This expression has type int -> int
281278
but an expression was expected of type string
282-
because [@error_message]: custom message
279+
custom message
283280
|}]

ocaml/typing/typecore.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8373,7 +8373,7 @@ let report_type_expected_explanation expl ppf =
83738373
| Comprehension_when ->
83748374
because "a when-clause in a comprehension"
83758375
| Error_message_attr msg ->
8376-
fprintf ppf "@ because [@error_message]: %s" msg
8376+
fprintf ppf "@\n@[%s@]" msg
83778377
83788378
let escaping_hint failure_reason submode_reason
83798379
(context : Env.closure_context option) =

0 commit comments

Comments
 (0)