Skip to content

Commit 5438881

Browse files
gaschergrinberg
andcommitted
Remove warning 30 from the standard set.
Warning 30 (same constructor/label name used in two mutually-recursive declarations) is an annoying warning that makes no sense since we introduced type-based disambiguation of fields and constructors. It was disabled by default in OCaml 4.10 ocaml/ocaml#9046 and there is no reason to keep it in Dune. Signed-off-by: Gabriel Scherer <[email protected]> Co-authored-by: Rudi Grinberg <[email protected]>
1 parent f6becad commit 5438881

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

doc/changes/9568.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Remove warning 30 from default set for projects where dune lang is at least
2+
3.13 (#9568, @gasche)

src/dune_rules/ocaml_flags.ml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ let dev_mode_warnings =
1313
(Int.Set.of_list
1414
[ 4; 29; 40; 41; 42; 44; 45; 48; 58; 59; 60; 63; 64; 65; 66; 67; 68; 69; 70 ])
1515
in
16+
let add n range = Int.Set.add range n in
17+
let remove n range = Int.Set.remove range n in
1618
let warnings_range ws =
1719
let wrange_to_flag (x, y) =
1820
if x = y then sprintf "@%d" x else sprintf "@%d..%d" x y
@@ -25,10 +27,22 @@ let dev_mode_warnings =
2527
|> List.rev_map ~f:wrange_to_flag
2628
|> String.concat ~sep:""
2729
in
28-
let pre_3_3 = lazy (warnings_range all) in
29-
let post_3_3 = lazy (warnings_range (Int.Set.union all (Int.Set.of_list [ 67; 69 ]))) in
30+
let and_warnings lazy_range =
31+
lazy_range, lazy (warnings_range (Lazy.force lazy_range))
32+
in
33+
let range_pre_3_3, pre_3_3 = and_warnings @@ lazy all in
34+
let range_pre_3_13, pre_3_13 =
35+
and_warnings @@ lazy (Lazy.force range_pre_3_3 |> add 67 |> add 69)
36+
in
37+
let _range_later, later =
38+
and_warnings @@ lazy (Lazy.force range_pre_3_13 |> remove 30)
39+
in
3040
fun ~dune_version ->
31-
if dune_version >= (3, 3) then Lazy.force post_3_3 else Lazy.force pre_3_3
41+
if dune_version < (3, 3)
42+
then Lazy.force pre_3_3
43+
else if dune_version < (3, 13)
44+
then Lazy.force pre_3_13
45+
else Lazy.force later
3246
;;
3347

3448
let vendored_warnings = [ "-w"; "-a" ]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
$ cat >dune <<EOF
2+
> (library
3+
> (modes byte)
4+
> (name foo))
5+
> EOF
6+
7+
$ cat >foo.ml <<EOF
8+
> type a = { a : int }
9+
> and b = { a : int ; b : bool }
10+
> EOF
11+
12+
$ cat >dune-project <<EOF
13+
> (lang dune 3.12)
14+
> EOF
15+
$ dune build foo.cma
16+
File "foo.ml", line 2, characters 10-19:
17+
2 | and b = { a : int ; b : bool }
18+
^^^^^^^^^
19+
Error (warning 30 [duplicate-definitions]): the label a is defined in both types a and b.
20+
[1]
21+
22+
$ cat >dune-project <<EOF
23+
> (lang dune 3.13)
24+
> EOF
25+
$ dune build foo.cma

0 commit comments

Comments
 (0)