Skip to content

Commit

Permalink
Improve error when parsing several licenses
Browse files Browse the repository at this point in the history
Closes ocaml#6103

Signed-off-by: Etienne Millon <me@emillon.org>
  • Loading branch information
emillon committed Sep 6, 2022
1 parent 5bb52cd commit ed17232
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------------

Expand Down
12 changes: 8 additions & 4 deletions src/dune_engine/package.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions test/blackbox-tests/test-cases/dune-project-meta/main.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ed17232

Please sign in to comment.