diff --git a/CHANGES.md b/CHANGES.md index 378d6fdc6ec..db2be3ea961 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -42,6 +42,9 @@ - Fix compilation of Dune under esy on Windows (#6109, fixes #6098, @nojb) +- Improve error message when parsing several licenses in `(license)` (#6114, + fixes #6103, @emillon) + 3.4.1 (26-07-2022) ------------------ diff --git a/src/dune_engine/package.ml b/src/dune_engine/package.ml index 88812049180..0720e58cb83 100644 --- a/src/dune_engine/package.ml +++ b/src/dune_engine/package.ml @@ -498,10 +498,14 @@ module Info = struct (Dune_lang.Syntax.since Stanza.syntax (v (1, 9)) >>> repeat string) and+ license = field_o "license" - (Dune_lang.Syntax.since Stanza.syntax (v (3, 2)) - >>> repeat1 string - <|> ( Dune_lang.Syntax.since Stanza.syntax (v (1, 9)) >>> string - >>| fun s -> [ s ] )) + (Dune_lang.Syntax.since Stanza.syntax (v (1, 9)) + >>> let* l = repeat1 string in + (if List.length l > 1 then + Dune_lang.Syntax.since ~what:"Parsing several licenses" + Stanza.syntax + (v (3, 2)) + else return ()) + >>> return l) and+ homepage = field_o "homepage" (Dune_lang.Syntax.since Stanza.syntax (v (1, 10)) >>> string) diff --git a/test/blackbox-tests/test-cases/dune-project-meta/main.t/run.t b/test/blackbox-tests/test-cases/dune-project-meta/main.t/run.t index 3abc61185d2..ab238ea052c 100644 --- a/test/blackbox-tests/test-cases/dune-project-meta/main.t/run.t +++ b/test/blackbox-tests/test-cases/dune-project-meta/main.t/run.t @@ -606,10 +606,11 @@ Reject multiple licences in version [1.9, 3.2) > EOF $ dune build - File "dune-project", line 4, characters 13-16: + File "dune-project", line 4, characters 0-17: 4 | (license MIT ISC) - ^^^ - Error: Too many argument for license + ^^^^^^^^^^^^^^^^^ + Error: Parsing several licenses is only available since version 3.2 of the + dune language. Please update your dune-project file to have (lang dune 3.2). [1] Allow multiple licences in version >= 3.2