Skip to content

Commit 0c24454

Browse files
committed
Make it an error for lang >= 3.0
Signed-off-by: Etienne Millon <[email protected]>
1 parent 13fe495 commit 0c24454

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/dune_lang/syntax.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ module Version = struct
3232
match Scanf.sscanf s "%u.%u%s" (fun a b s -> ((a, b), s)) with
3333
| Ok (v, "") -> v
3434
| Ok (((a, b) as v), s) ->
35-
User_warning.emit ~loc
35+
let is_error = v >= (3, 0) in
36+
User_warning.emit ~loc ~is_error
3637
[ Pp.textf "The %S part is ignored here." s
3738
; Pp.textf "This version is parsed as just %d.%d." a b
3839
];

test/blackbox-tests/test-cases/lang-dune-warning.t

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
If (lang dune) does not use a valid format, a warning is emitted:
1+
If (lang dune) does not use a valid format on a 2.x project, a warning is
2+
emitted:
23

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

25-
Of course if the version is valid, no warning is emitted:
26+
If the version is valid, no warning is emitted:
2627

2728
$ cat > dune-project << EOF
2829
> (lang dune 2.2)
2930
> EOF
3031

3132
$ dune build
33+
34+
Starting with lang 3.0, the warning turns into an error.
35+
36+
$ cat > dune-project << EOF
37+
> (lang dune 3.0suffix)
38+
> EOF
39+
40+
$ dune build
41+
File "dune-project", line 1, characters 11-20:
42+
1 | (lang dune 3.0suffix)
43+
^^^^^^^^^
44+
Error: The "suffix" part is ignored here.
45+
This version is parsed as just 3.0.
46+
[1]
47+
48+
And without suffix it is accepted.
49+
50+
$ cat > dune-project << EOF
51+
> (lang dune 3.0)
52+
> EOF
53+
54+
$ dune build

0 commit comments

Comments
 (0)