Skip to content

Commit

Permalink
Merge pull request #1919 from rgrinberg/fix-1918
Browse files Browse the repository at this point in the history
Fix 1918
  • Loading branch information
rgrinberg authored Mar 8, 2019
2 parents 9204f6d + 92fb4b2 commit 6b14924
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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)
------------------

Expand Down
14 changes: 8 additions & 6 deletions src/dune_lang/atom.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion src/dune_package.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down

0 comments on commit 6b14924

Please sign in to comment.