Improve error message for renamed forms
Don't include the payload in these messages Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
78140ca235
commit
1b918ecc74
|
@ -217,8 +217,11 @@ module Var = struct
|
|||
|
||||
let sexp_of_t t = Sexp.atom (to_string t)
|
||||
|
||||
let rename t ~new_name =
|
||||
{ t with name = new_name }
|
||||
let with_payload t ~payload =
|
||||
{ t with payload }
|
||||
|
||||
let with_name t ~name =
|
||||
{ t with name }
|
||||
|
||||
let is_form t = Option.is_some t.payload
|
||||
end
|
||||
|
|
|
@ -65,7 +65,9 @@ module Var : sig
|
|||
|
||||
val to_string : t -> string
|
||||
|
||||
val rename : t -> new_name:string -> t
|
||||
val with_name : t -> name:string -> t
|
||||
|
||||
val with_payload : t -> payload:string option -> t
|
||||
|
||||
val is_form : t -> bool
|
||||
end
|
||||
|
|
|
@ -233,8 +233,8 @@ end = struct
|
|||
let rec expand t ~syntax_version ~var =
|
||||
let name = String_with_vars.Var.name var in
|
||||
Option.bind (String.Map.find t name) ~f:(fun v ->
|
||||
let what =
|
||||
lazy (sprintf "Variable %s" (String_with_vars.Var.to_string var)) in
|
||||
let what var =
|
||||
sprintf "Variable %s" (String_with_vars.Var.to_string var) in
|
||||
match v with
|
||||
| No_info v -> Some v
|
||||
| Since (v, min_version) ->
|
||||
|
@ -243,23 +243,30 @@ end = struct
|
|||
else
|
||||
Syntax.Error.since (String_with_vars.Var.loc var)
|
||||
Stanza.syntax syntax_version
|
||||
~what:(Lazy.force what)
|
||||
~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:(Lazy.force what)
|
||||
~to_:(String_with_vars.Var.(to_string (rename var ~new_name)))
|
||||
~what:(what var)
|
||||
~to_:(let open String_with_vars.Var in
|
||||
to_string (with_name var ~name:new_name))
|
||||
else
|
||||
expand t ~syntax_version:in_version
|
||||
~var:(String_with_vars.Var.rename var ~new_name)
|
||||
~var:(String_with_vars.Var.with_name var ~name:new_name)
|
||||
end
|
||||
| Deleted_in (v, in_version) ->
|
||||
if syntax_version < in_version then
|
||||
Some v
|
||||
else
|
||||
Syntax.Error.deleted_in (String_with_vars.Var.loc var)
|
||||
Stanza.syntax syntax_version ~what:(Lazy.force what))
|
||||
Stanza.syntax syntax_version ~what:(what var))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -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:pkg} was renamed to '%{lib:pkg}' in the 1.0 version of the dune language
|
||||
Error: Variable %{findlib:..} was renamed to '%{lib:..}' in the 1.0 version of the dune language
|
||||
[1]
|
||||
|
||||
But it must still be available in jbuild files
|
||||
|
|
|
@ -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:file-that-does-not-exist} was renamed to '%{dep:file-that-does-not-exist}' in the 1.0 version of the dune language
|
||||
Error: Variable %{path:..} was renamed to '%{dep:..}' in the 1.0 version of the dune language
|
||||
[1]
|
||||
|
||||
%{path-no-dep:string}
|
||||
|
|
Loading…
Reference in New Issue