Skip to content

Commit c9e5bf2

Browse files
authored
[Super errors] Specialize error msgs for Reason syntax when needed (#2616)
See the updated error/warning msgs As per feedback, we're gonna do it for Reason syntax for now. We'll add back the support for OCaml syntax later.
1 parent 87f4d74 commit c9e5bf2

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

jscomp/super_errors/super_typecore.ml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,19 @@ let report_error env ppf = function
228228
type_expr typ;
229229
fprintf ppf "@ @[It only accepts %i %s; here, it's called with more.@]@]"
230230
acceptsCount (if acceptsCount == 1 then "argument" else "arguments")
231-
| Tconstr ((Path.Pdot (((Pdot (Path.Pident {name="Js"}, "Internal", _))| (Pident {name="Js_internal"})), ("fn" | "meth"), _)), _, _)
232-
-> fprintf ppf "This is an uncurried bucklescript function. It must be applied with [@bs]."
231+
| Tconstr (
232+
(Path.Pdot (((Pdot (Path.Pident {name="Js"}, "Internal", _)) | (Pident {name="Js_internal"})), ("fn" | "meth"), _)),
233+
_,
234+
_
235+
)
236+
->
237+
fprintf
238+
ppf
239+
"@[<v>This is an uncurried BuckleScript function. @{<info>It must be applied with a dot@}.@,@,\
240+
Like this: @{<info>foo(. a, b)@}@,\
241+
Not like this: @{<dim>foo(a, b)@}@,@,\
242+
This guarantees that your function is fully applied. More info here:@,\
243+
https://bucklescript.github.io/docs/en/function.html#solution-guaranteed-uncurrying@]"
233244
| _ ->
234245
fprintf ppf "@[<v>@[<2>This expression has type@ %a@]@ %s@]"
235246
type_expr typ

jscomp/super_errors/super_warnings.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ let message (warning : Warnings.t) =
1818
"This file's name is potentially invalid. The build systems conventionally turn a file name into a module name by upper-casing the first letter. " ^ modname ^ " isn't a valid module name.\n" ^
1919
"Note: some build systems might e.g. turn kebab-case into CamelCase module, which is why this isn't a hard error."
2020
| Statement_type -> "This expression returns a value, but you're not doing anything with it. If this is on purpose, put `|> ignore` at the end."
21+
| Useless_record_with ->
22+
"All the fields are already explicitly listed in this record. You can remove the `...` spread."
2123
| _ -> Warnings.message warning
2224
;;

0 commit comments

Comments
 (0)