From 9d3117d63ed5762771da9ed2d006ea9a70781b27 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Thu, 17 May 2018 15:46:09 +0100 Subject: [PATCH] Fix bug exposed by previous commit --- CHANGES.md | 3 +++ src/stdune/sexp.ml | 2 ++ test/unit-tests/sexp.mlt | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 711e5337..bbb87043 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -43,6 +43,9 @@ next - Add an `ignored_subdirs` stanza to replace `jbuild-ignore` files (#767, @diml) +- Fix a bug where Dune ignored previous occurences of duplicated + fields (#779, @diml) + 1.0+beta20 (10/04/2018) ----------------------- diff --git a/src/stdune/sexp.ml b/src/stdune/sexp.ml index cac9b1d4..f6f68470 100644 --- a/src/stdune/sexp.ml +++ b/src/stdune/sexp.ml @@ -273,6 +273,8 @@ module Of_sexp = struct | List (_, name_sexp :: values) -> begin match name_sexp with | Atom (_, A name) -> + if Name_map.mem acc name then + of_sexp_errorf sexp "Field %S is present too many times" name; Name_map.add acc name { values; entry = sexp } | List _ | Quoted_string _ -> of_sexp_error name_sexp "Atom expected" diff --git a/test/unit-tests/sexp.mlt b/test/unit-tests/sexp.mlt index 114dd78b..826c7d42 100644 --- a/test/unit-tests/sexp.mlt +++ b/test/unit-tests/sexp.mlt @@ -27,5 +27,7 @@ let of_sexp = record (field "foo" int) let x = of_sexp sexp [%%expect{| val of_sexp : int Stdune.Sexp.Of_sexp.t = -val x : int = 2 +Exception: +Stdune__Sexp.Of_sexp.Of_sexp (, + "Field \"foo\" is present too many times", None). |}]