Skip to content

Commit 38cbd10

Browse files
committed
[Super errors] Tweak type mismatch to be more compact
Will help the editor error message displays
1 parent 1132eb2 commit 38cbd10

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

jscomp/super_errors/super_location.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ let super_warning_printer loc ppf w =
8585
match Warnings.report w with
8686
| `Inactive -> ()
8787
| `Active { Warnings. number = _; message = _; sub_locs = _} ->
88-
setup_colors ();
89-
Format.fprintf ppf "@[<v 2>@,%a@,%s@,@]"
88+
setup_colors ();
89+
Format.fprintf ppf "@[<v 2>@,%a@,%s@,@]@."
9090
(print ("Warning number " ^ (Warnings.number w |> string_of_int)))
9191
loc
9292
(Warnings.message w);

jscomp/super_errors/super_typecore.ml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ let simple_conversions = [
3737
let print_simple_conversion ppf (actual, expected) =
3838
try (
3939
let converter = List.assoc (actual, expected) simple_conversions in
40-
Format.pp_print_newline ppf ();
41-
fprintf ppf "@[<v 2>@,You can convert @{<info>%s@} to @{<info>%s@} with @{<info>%s@}.@]" actual expected converter
40+
fprintf ppf "@,@,@[<v 2>You can convert @{<info>%s@} to @{<info>%s@} with @{<info>%s@}.@]" actual expected converter
4241
) with | Not_found -> ()
4342

4443
let print_simple_message ppf = function
@@ -135,7 +134,7 @@ let print_expr_type_clash env trace ppf =
135134
(function ppf ->
136135
fprintf ppf "This has type:")
137136
(function ppf ->
138-
fprintf ppf "But somewhere wanted:");
137+
fprintf ppf "Somewhere wanted:");
139138
show_extra_help ppf env trace;
140139
end
141140

@@ -178,21 +177,21 @@ let report_error env ppf = function
178177
fprintf ppf "The variable %s on the left-hand side of this or-pattern has type" (Ident.name id))
179178
(function ppf ->
180179
fprintf ppf "but on the right-hand side it has type")
181-
| Expr_type_clash (
180+
| Expr_type_clash (
182181
(_, {desc = Tarrow _}) ::
183182
(_, {desc = Tconstr (Pdot (Pdot(Pident {name = "Js"},"Fn",_),_,_),_,_)}) :: _
184-
) ->
185-
fprintf ppf "This function is a curried function where an uncurried function is expected"
183+
) ->
184+
fprintf ppf "This function is a curried function where an uncurried function is expected"
186185
| Expr_type_clash (
187186
(_, {desc = Tconstr (Pdot (Pdot(Pident {name = "Js"},"Fn",_),a,_),_,_)}) ::
188187
(_, {desc = Tconstr (Pdot (Pdot(Pident {name = "Js"},"Fn",_),b,_),_,_)}) :: _
189-
) when a <> b ->
190-
fprintf ppf "This function has %s but was expected %s" a b
191-
| Expr_type_clash (
188+
) when a <> b ->
189+
fprintf ppf "This function has %s but was expected %s" a b
190+
| Expr_type_clash (
192191
(_, {desc = Tconstr (Pdot (Pdot(Pident {name = "Js_OO"},"Meth",_),a,_),_,_)}) ::
193192
(_, {desc = Tconstr (Pdot (Pdot(Pident {name = "Js_OO"},"Meth",_),b,_),_,_)}) :: _
194-
) when a <> b ->
195-
fprintf ppf "This method has %s but was expected %s" a b
193+
) when a <> b ->
194+
fprintf ppf "This method has %s but was expected %s" a b
196195

197196
| Expr_type_clash trace ->
198197
(* modified *)
@@ -254,10 +253,10 @@ let report_error env ppf = function
254253
fprintf ppf "it should have type@ %a@]"
255254
type_expr ty
256255
end else begin
257-
match ty with
258-
| {desc = Tconstr (Pdot (Pdot(Pident {name = "Js"},"Fn",_),_,_),_,_)} ->
256+
match ty with
257+
| {desc = Tconstr (Pdot (Pdot(Pident {name = "Js"},"Fn",_),_,_),_,_)} ->
259258
fprintf ppf "This expression is excpeted to have an uncurried function"
260-
| _ ->
259+
| _ ->
261260
fprintf ppf "@[This expression should not be a function,@ ";
262261
fprintf ppf "the expected type is@ %a@]"
263262
type_expr ty

0 commit comments

Comments
 (0)