From 056414cd6146a9fc5dc907adb6e542a31df288eb Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 8 Mar 2019 11:40:35 +0700 Subject: [PATCH 1/2] Remove invalid_arg usage We can just use stdune in dune_lang now Signed-off-by: Rudi Grinberg --- src/dune_lang/atom.ml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/dune_lang/atom.ml b/src/dune_lang/atom.ml index bc1e5f9a1bc..d214e11f102 100644 --- a/src/dune_lang/atom.ml +++ b/src/dune_lang/atom.ml @@ -2,8 +2,6 @@ open Stdune type t = A of string [@@unboxed] -let invalid_argf fmt = Printf.ksprintf invalid_arg fmt - let is_valid_dune = let rec loop s i len = i = len || @@ -42,13 +40,17 @@ let is_valid (A t) = function | Syntax.Jbuild -> is_valid_jbuild t | Dune -> is_valid_dune t -let print ((A s) as t) syntax = +let print ((A atom) as t) syntax = if is_valid t syntax then - s + atom else match syntax with - | Jbuild -> invalid_argf "atom '%s' cannot be printed in jbuild syntax" s - | Dune -> invalid_argf "atom '%s' cannot be in dune syntax" s + | Jbuild -> + Exn.code_error "atom cannot be printed in jbuild syntax" + ["atom", Sexp.Atom atom] + | Dune -> + Exn.code_error "atom cannot be printed in dune syntax" + ["atom", Sexp.Atom atom] let of_int i = of_string (string_of_int i) let of_float x = of_string (string_of_float x) From 92fb4b28eab0ca5d915e2460bd5f09fc924ae326 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 8 Mar 2019 11:40:51 +0700 Subject: [PATCH 2/2] Fix version encoding in dune-package Empty versions are now omitted and the versions are quoted if necessary Signed-off-by: Rudi Grinberg --- CHANGES.md | 6 ++++++ src/dune_package.ml | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 8ea14ed7614..ff924c8d51c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +1.8.1 (08/03/2019) +------------------ + +- Correctly write `dune-package` when version is empty string (#1919, fix #1918, + @rgrinberg) + 1.8.0 (07/03/2019) ------------------ diff --git a/src/dune_package.ml b/src/dune_package.ml index fba362515df..bbb7a24bf7c 100644 --- a/src/dune_package.ml +++ b/src/dune_package.ml @@ -229,7 +229,10 @@ let encode ~dune_version { libs ; name ; version; dir } = match version with | None -> sexp | Some version -> - sexp @ [List [Dune_lang.atom "version"; Dune_lang.atom version]] + sexp @ [ List [ Dune_lang.atom "version" + ; Dune_lang.atom_or_quoted_string version + ] + ] in let libs = List.map libs ~f:(fun lib ->