diff --git a/src/dune_lang/syntax.ml b/src/dune_lang/syntax.ml index 6eecca4fa375..ef32cb245637 100644 --- a/src/dune_lang/syntax.ml +++ b/src/dune_lang/syntax.ml @@ -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 ]; diff --git a/test/blackbox-tests/test-cases/lang-dune-warning.t b/test/blackbox-tests/test-cases/lang-dune-warning.t index 778d4a834213..0d94245b20f0 100644 --- a/test/blackbox-tests/test-cases/lang-dune-warning.t +++ b/test/blackbox-tests/test-cases/lang-dune-warning.t @@ -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) @@ -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