Merge pull request #1126 from ocaml/ambiguous-package-more-precise-error
Display actual stanza when package is ambiguous
This commit is contained in:
commit
a99c73bbef
|
@ -9,6 +9,8 @@ next
|
|||
|
||||
- Highlight error locations in error messages (#1121, @emillon)
|
||||
|
||||
- Display actual stanza when package is ambiguous (#1126, fix #1123, @emillon)
|
||||
|
||||
1.1.1 (08/08/2018)
|
||||
------------------
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ module Pkg = struct
|
|||
(Package.Name.to_string pkg.Package.name)
|
||||
(Path.to_string (Package.opam_file pkg))))
|
||||
|
||||
let default (project : Dune_project.t) =
|
||||
let default (project : Dune_project.t) stanza =
|
||||
match Package.Name.Map.values project.packages with
|
||||
| [pkg] -> Ok pkg
|
||||
| [] ->
|
||||
|
@ -178,11 +178,12 @@ module Pkg = struct
|
|||
| _ :: _ :: _ ->
|
||||
Error
|
||||
(sprintf
|
||||
"I can't determine automatically which package this (install ...) \
|
||||
stanza is for. I have the choice between these ones:\n\
|
||||
"I can't determine automatically which package this \
|
||||
stanza is for.\nI have the choice between these ones:\n\
|
||||
%s\n\
|
||||
You need to add a (package ...) field in this (install ...) stanza"
|
||||
(listing (Package.Name.Map.values project.packages)))
|
||||
You need to add a (package ...) field to this (%s) stanza."
|
||||
(listing (Package.Name.Map.values project.packages))
|
||||
stanza)
|
||||
|
||||
let resolve (project : Dune_project.t) name =
|
||||
match Package.Name.Map.find project.packages name with
|
||||
|
@ -215,14 +216,14 @@ module Pkg = struct
|
|||
| Ok x -> x
|
||||
| Error e -> Loc.fail loc "%s" e
|
||||
|
||||
let field =
|
||||
let field stanza =
|
||||
map_validate
|
||||
(let%map p = Dune_project.get_exn ()
|
||||
and pkg = field_o "package" string in
|
||||
(p, pkg))
|
||||
~f:(fun (p, pkg) ->
|
||||
match pkg with
|
||||
| None -> default p
|
||||
| None -> default p stanza
|
||||
| Some name -> resolve p (Package.Name.of_string name))
|
||||
end
|
||||
|
||||
|
@ -1049,7 +1050,7 @@ module Install_conf = struct
|
|||
record
|
||||
(let%map section = field "section" Install.Section.t
|
||||
and files = field "files" (list file)
|
||||
and package = Pkg.field
|
||||
and package = Pkg.field "install"
|
||||
in
|
||||
{ section
|
||||
; files
|
||||
|
@ -1168,9 +1169,9 @@ module Executables = struct
|
|||
|
||||
let pluralize s ~multi =
|
||||
if multi then
|
||||
s
|
||||
else
|
||||
s ^ "s"
|
||||
else
|
||||
s
|
||||
|
||||
let common =
|
||||
let%map buildable = Buildable.t
|
||||
|
@ -1289,7 +1290,10 @@ module Executables = struct
|
|||
match
|
||||
match package with
|
||||
| None ->
|
||||
(buildable.loc, Pkg.default project)
|
||||
let stanza =
|
||||
pluralize ~multi "executable"
|
||||
in
|
||||
(buildable.loc, Pkg.default project stanza)
|
||||
| Some (loc, name) ->
|
||||
(loc, Pkg.resolve project (Package.Name.of_string name))
|
||||
with
|
||||
|
@ -1705,7 +1709,7 @@ module Documentation = struct
|
|||
|
||||
let t =
|
||||
record
|
||||
(let%map package = Pkg.field
|
||||
(let%map package = Pkg.field "documentation"
|
||||
and mld_files = Ordered_set_lang.field "mld_files"
|
||||
and loc = loc in
|
||||
{ loc
|
||||
|
|
|
@ -708,6 +708,14 @@
|
|||
test-cases/select
|
||||
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
|
||||
|
||||
(alias
|
||||
(name several-packages)
|
||||
(deps (package dune) (source_tree test-cases/several-packages))
|
||||
(action
|
||||
(chdir
|
||||
test-cases/several-packages
|
||||
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
|
||||
|
||||
(alias
|
||||
(name shadow-bindings)
|
||||
(deps (package dune) (source_tree test-cases/shadow-bindings))
|
||||
|
@ -867,6 +875,7 @@
|
|||
(alias scope-bug)
|
||||
(alias scope-ppx-bug)
|
||||
(alias select)
|
||||
(alias several-packages)
|
||||
(alias shadow-bindings)
|
||||
(alias subst)
|
||||
(alias syntax-versioning)
|
||||
|
@ -953,6 +962,7 @@
|
|||
(alias reporting-of-cycles)
|
||||
(alias scope-bug)
|
||||
(alias select)
|
||||
(alias several-packages)
|
||||
(alias shadow-bindings)
|
||||
(alias subst)
|
||||
(alias syntax-versioning)
|
||||
|
|
|
@ -19,7 +19,7 @@ executable(s) stanza works the same way
|
|||
File "dune", line 1, characters 0-36:
|
||||
(executables (public_names foo bar))
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Error: name field may not be omitted before dune version 1.1
|
||||
Error: names field may not be omitted before dune version 1.1
|
||||
[1]
|
||||
|
||||
there's only a public name but it's invalid as a name
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
(documentation)
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.1)
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.1)
|
|
@ -0,0 +1,3 @@
|
|||
(executable
|
||||
(public_name an_executable)
|
||||
)
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.1)
|
|
@ -0,0 +1,4 @@
|
|||
(install
|
||||
(section etc)
|
||||
(files file.conf)
|
||||
)
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.1)
|
|
@ -0,0 +1,37 @@
|
|||
If two packages are available and no (package) is present, an error message is
|
||||
displayed. This can happen for:
|
||||
|
||||
- (executable)
|
||||
|
||||
$ dune build --root executable
|
||||
File "dune", line 1, characters 0-43:
|
||||
Error: I can't determine automatically which package this stanza is for.
|
||||
I have the choice between these ones:
|
||||
- pkg1 (because of pkg1.opam)
|
||||
- pkg2 (because of pkg2.opam)
|
||||
You need to add a (package ...) field to this (executable) stanza.
|
||||
[1]
|
||||
|
||||
- (documentation)
|
||||
|
||||
$ dune build --root documentation
|
||||
File "dune", line 1, characters 0-15:
|
||||
(documentation)
|
||||
^^^^^^^^^^^^^^^
|
||||
Error: I can't determine automatically which package this stanza is for.
|
||||
I have the choice between these ones:
|
||||
- pkg1 (because of pkg1.opam)
|
||||
- pkg2 (because of pkg2.opam)
|
||||
You need to add a (package ...) field to this (documentation) stanza.
|
||||
[1]
|
||||
|
||||
- (install)
|
||||
|
||||
$ dune build --root install
|
||||
File "dune", line 1, characters 0-44:
|
||||
Error: I can't determine automatically which package this stanza is for.
|
||||
I have the choice between these ones:
|
||||
- pkg1 (because of pkg1.opam)
|
||||
- pkg2 (because of pkg2.opam)
|
||||
You need to add a (package ...) field to this (install) stanza.
|
||||
[1]
|
Loading…
Reference in New Issue