Improve error messages for all forms

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-07-08 16:23:40 +07:00
parent 813b8d9dbc
commit 7cb068d1eb
4 changed files with 12 additions and 14 deletions

View File

@ -151,7 +151,12 @@ module Map = struct
let name = String_with_vars.Var.name var in
Option.bind (String.Map.find t name) ~f:(fun v ->
let what var =
sprintf "Variable %s" (String_with_vars.Var.to_string var) in
String_with_vars.Var.to_string (
if String_with_vars.Var.is_form var then
String_with_vars.Var.with_payload var ~payload:(Some "..")
else
var)
in
match v with
| No_info v -> Some v
| Since (v, min_version) ->
@ -163,17 +168,10 @@ module Map = struct
~what:(what var)
| Renamed_in (in_version, new_name) -> begin
if syntax_version >= in_version then
let var =
if String_with_vars.Var.is_form var then
String_with_vars.Var.with_payload var ~payload:(Some "..")
else
var
in
Syntax.Error.renamed_in (String_with_vars.Var.loc var)
Stanza.syntax syntax_version
~what:(what var)
~to_:(let open String_with_vars.Var in
to_string (with_name var ~name:new_name))
~to_:(what (String_with_vars.Var.with_name var ~name:new_name))
else
expand t ~syntax_version:in_version
~var:(String_with_vars.Var.with_name var ~name:new_name)

View File

@ -6,7 +6,7 @@ All builtin variables are lower cased in Dune:
$ dune runtest --root dune-upper
Entering directory 'dune-upper'
File "dune", line 3, characters 41-46:
Error: Variable %{MAKE} was renamed to '%{make}' in the 1.0 version of the dune language
Error: %{MAKE} was renamed to '%{make}' in the 1.0 version of the dune language
[1]
jbuild files retain the the old names:

View File

@ -3,7 +3,7 @@ We are dropping support for findlib in dune
$ dune build --root in-dune target.txt
Entering directory 'in-dune'
File "dune", line 2, characters 25-37:
Error: Variable %{findlib:..} was renamed to '%{lib:..}' in the 1.0 version of the dune language
Error: %{findlib:..} was renamed to '%{lib:..}' in the 1.0 version of the dune language
[1]
But it must still be available in jbuild files

View File

@ -9,7 +9,7 @@ In expands to a file name, and registers this as a dependency.
$ dune build --root dune @test-dep
Entering directory 'dune'
File "dune", line 13, characters 17-47:
Error: Variable %{path:..} was renamed to '%{dep:..}' in the 1.0 version of the dune language
Error: %{path:..} was renamed to '%{dep:..}' in the 1.0 version of the dune language
[1]
%{path-no-dep:string}
@ -20,7 +20,7 @@ This form does not exist, but displays an hint:
$ dune build --root dune-invalid @test-path-no-dep
Entering directory 'dune-invalid'
File "dune", line 7, characters 17-54:
Error: Variable %{path-no-dep:file-that-does-not-exist} was deleted in version 1.0 of the dune language
Error: %{path-no-dep:..} was deleted in version 1.0 of the dune language
[1]
jbuild files
@ -53,5 +53,5 @@ This form does not exist, but displays an hint:
$ dune build --root jbuild-invalid @test-dep
Entering directory 'jbuild-invalid'
File "jbuild", line 5, characters 16-37:
Error: Variable ${dep:generated-file} is only available since version 1.0 of the dune language
Error: ${dep:..} is only available since version 1.0 of the dune language
[1]