Skip to content

Commit

Permalink
Restrict the name when there's only one package
Browse files Browse the repository at this point in the history
it should always be the same as the project name

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
  • Loading branch information
rgrinberg committed Apr 30, 2019
1 parent 3f48744 commit 90179b0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/dune_project.ml
Original file line number Diff line number Diff line change
Expand Up @@ -614,15 +614,24 @@ let parse ~dir ~lang ~packages ~file =
let allow_approx_merlin =
Option.value ~default:false allow_approx_merlin in
let packages =
begin match dune_defined_packages, name with
| [loc, p], Named name ->
if Package.Name.to_string p.name <> name then
of_sexp_errorf loc
"when a single package is defined, it must have the same \
name as the project name: %s" name;
| _, _ -> ()
end;
match
dune_defined_packages
|> Package.Name.Map.of_list_map
~f:(fun (_loc, (p : Package.t)) -> p.name, p)
dune_defined_packages
|> Package.Name.Map.of_list_map
~f:(fun (_loc, (p : Package.t)) -> p.name, p)
with
| Error (p, (_, _), (loc, _)) ->
of_sexp_errorf loc "package %s is already defined"
(Package.Name.to_string p)
| Ok d -> Package.Name.Map.superpose packages d
| Ok d ->
Package.Name.Map.superpose packages d
in
{ name
; root = dir
Expand Down

0 comments on commit 90179b0

Please sign in to comment.