Capitalize module names in errors messages

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-09-04 15:26:29 +04:00
parent fbc0284132
commit b76211b916
3 changed files with 9 additions and 13 deletions

View File

@ -121,6 +121,11 @@ end = struct
in in
let uncapitalized = let uncapitalized =
List.map ~f:(fun (_, m) -> Module.name m |> Module.Name.uncapitalize) in List.map ~f:(fun (_, m) -> Module.name m |> Module.Name.uncapitalize) in
let line_list modules =
List.map ~f:(fun (_, m) ->
Module.name m |> Module.Name.to_string |> sprintf "- %s") modules
|> String.concat ~sep:"\n"
in
begin match virt_intf_overlaps with begin match virt_intf_overlaps with
| [] -> () | [] -> ()
| (loc, _) :: _ -> | (loc, _) :: _ ->
@ -128,11 +133,7 @@ end = struct
"These modules appear in the virtual_libraries \ "These modules appear in the virtual_libraries \
and modules_without_implementation fields: \ and modules_without_implementation fields: \
\n%s\nThis is not possible." \n%s\nThis is not possible."
(virt_intf_overlaps (line_list virt_intf_overlaps)
|> uncapitalized
|> List.map ~f:(sprintf "- %s")
|> String.concat ~sep:"\n"
)
end; end;
if missing_intf_only <> [] then begin if missing_intf_only <> [] then begin
match Ordered_set_lang.loc buildable.modules_without_implementation with match Ordered_set_lang.loc buildable.modules_without_implementation with
@ -153,17 +154,12 @@ end = struct
in in
Dsexp.to_string ~syntax:Dune (List (tag :: modules))) Dsexp.to_string ~syntax:Dune (List (tag :: modules)))
| Some loc -> | Some loc ->
let list_modules l =
uncapitalized l
|> List.map ~f:(sprintf "- %s")
|> String.concat ~sep:"\n"
in
Errors.warn loc Errors.warn loc
"The following modules must be listed here as they don't \ "The following modules must be listed here as they don't \
have an implementation:\n\ have an implementation:\n\
%s\n\ %s\n\
This will become an error in the future." This will become an error in the future."
(list_modules missing_intf_only) (line_list missing_intf_only)
end; end;
begin match missing_modules with begin match missing_modules with
| [] -> () | [] -> ()

View File

@ -40,7 +40,7 @@ Errors:
3 | (modules_without_implementation x)) 3 | (modules_without_implementation x))
^ ^
Warning: The following modules must be listed here as they don't have an implementation: Warning: The following modules must be listed here as they don't have an implementation:
- y - Y
This will become an error in the future. This will become an error in the future.
ocamlc .foo.objs/foo.{cmi,cmo,cmt} ocamlc .foo.objs/foo.{cmi,cmo,cmt}
ocamlc foo.cma ocamlc foo.cma

View File

@ -42,7 +42,7 @@ virtual libraries may not implement their virtual modules
4 | (virtual_modules m)) 4 | (virtual_modules m))
^ ^
Error: These modules appear in the virtual_libraries and modules_without_implementation fields: Error: These modules appear in the virtual_libraries and modules_without_implementation fields:
- m - M
This is not possible. This is not possible.
------------------------- -------------------------
impl: false. modules_without_implementation: true. virtual_modules: false impl: false. modules_without_implementation: true. virtual_modules: false