Skip to content

Commit ed17232

Browse files
committed
Improve error when parsing several licenses
Closes #6103 Signed-off-by: Etienne Millon <me@emillon.org>
1 parent 5bb52cd commit ed17232

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

CHANGES.md

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242

4343
- Fix compilation of Dune under esy on Windows (#6109, fixes #6098, @nojb)
4444

45+
- Improve error message when parsing several licenses in `(license)` (#6114,
46+
fixes #6103, @emillon)
47+
4548
3.4.1 (26-07-2022)
4649
------------------
4750

src/dune_engine/package.ml

+8-4
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,14 @@ module Info = struct
498498
(Dune_lang.Syntax.since Stanza.syntax (v (1, 9)) >>> repeat string)
499499
and+ license =
500500
field_o "license"
501-
(Dune_lang.Syntax.since Stanza.syntax (v (3, 2))
502-
>>> repeat1 string
503-
<|> ( Dune_lang.Syntax.since Stanza.syntax (v (1, 9)) >>> string
504-
>>| fun s -> [ s ] ))
501+
(Dune_lang.Syntax.since Stanza.syntax (v (1, 9))
502+
>>> let* l = repeat1 string in
503+
(if List.length l > 1 then
504+
Dune_lang.Syntax.since ~what:"Parsing several licenses"
505+
Stanza.syntax
506+
(v (3, 2))
507+
else return ())
508+
>>> return l)
505509
and+ homepage =
506510
field_o "homepage"
507511
(Dune_lang.Syntax.since Stanza.syntax (v (1, 10)) >>> string)

test/blackbox-tests/test-cases/dune-project-meta/main.t/run.t

+4-3
Original file line numberDiff line numberDiff line change
@@ -606,10 +606,11 @@ Reject multiple licences in version [1.9, 3.2)
606606
> EOF
607607

608608
$ dune build
609-
File "dune-project", line 4, characters 13-16:
609+
File "dune-project", line 4, characters 0-17:
610610
4 | (license MIT ISC)
611-
^^^
612-
Error: Too many argument for license
611+
^^^^^^^^^^^^^^^^^
612+
Error: Parsing several licenses is only available since version 3.2 of the
613+
dune language. Please update your dune-project file to have (lang dune 3.2).
613614
[1]
614615

615616
Allow multiple licences in version >= 3.2

0 commit comments

Comments
 (0)