Skip to content

Commit

Permalink
Make it an error for lang >= 3.0
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne Millon <me@emillon.org>
  • Loading branch information
emillon committed Oct 27, 2021
1 parent 13fe495 commit 0c24454
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/dune_lang/syntax.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module Version = struct
match Scanf.sscanf s "%u.%u%s" (fun a b s -> ((a, b), s)) with
| Ok (v, "") -> v
| Ok (((a, b) as v), s) ->
User_warning.emit ~loc
let is_error = v >= (3, 0) in
User_warning.emit ~loc ~is_error
[ Pp.textf "The %S part is ignored here." s
; Pp.textf "This version is parsed as just %d.%d." a b
];
Expand Down
27 changes: 25 additions & 2 deletions test/blackbox-tests/test-cases/lang-dune-warning.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
If (lang dune) does not use a valid format, a warning is emitted:
If (lang dune) does not use a valid format on a 2.x project, a warning is
emitted:

$ cat > dune-project << EOF
> (lang dune 2.3.0)
Expand All @@ -22,10 +23,32 @@ If (lang dune) does not use a valid format, a warning is emitted:
Warning: The "suffix" part is ignored here.
This version is parsed as just 2.4.

Of course if the version is valid, no warning is emitted:
If the version is valid, no warning is emitted:

$ cat > dune-project << EOF
> (lang dune 2.2)
> EOF

$ dune build

Starting with lang 3.0, the warning turns into an error.

$ cat > dune-project << EOF
> (lang dune 3.0suffix)
> EOF

$ dune build
File "dune-project", line 1, characters 11-20:
1 | (lang dune 3.0suffix)
^^^^^^^^^
Error: The "suffix" part is ignored here.
This version is parsed as just 3.0.
[1]

And without suffix it is accepted.

$ cat > dune-project << EOF
> (lang dune 3.0)
> EOF

$ dune build

0 comments on commit 0c24454

Please sign in to comment.