From 453e602cff9890e303d4838035129e05635ace1c Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Fri, 2 Sep 2022 11:03:15 +0200 Subject: [PATCH] Improve error when parsing several licenses Closes #6103 Signed-off-by: Etienne Millon --- CHANGES.md | 3 +++ src/dune_engine/package.ml | 8 +++++--- .../test-cases/dune-project-meta/main.t/run.t | 7 ++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 495821bb1af6..6341ec6841dc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -38,6 +38,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 88812049180a..89fdd11cac77 100644 --- a/src/dune_engine/package.ml +++ b/src/dune_engine/package.ml @@ -498,10 +498,12 @@ 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)) + (Dune_lang.Syntax.since Stanza.syntax (v (1, 9)) >>> repeat1 string - <|> ( Dune_lang.Syntax.since Stanza.syntax (v (1, 9)) >>> string - >>| fun s -> [ s ] )) + ~check_multi: + (Dune_lang.Syntax.since ~what:"Parsing several licenses" + Stanza.syntax + (v (3, 2)))) 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 3abc61185d2b..ab238ea052cb 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