Checking dune files for semantic errors

Recently I’ve found two kinds of errors in one of our dune files:

  • A dirs stanza containing directories that do not exist, e.g. (dirs foo bar) when only foo exists.
  • A dune file inside a directory absent from a dirs stanza in the parent, which meant it was ignored.

In both cases Dune did not report anything.

To catch such kinds of silly mistakes, it would be useful to have tools that might detect these and similar ones. Not necessarily by default, but maybe in a “strict” mode.

Is there already something that does that?

Note that the second case is debatable, since a dirs stanza means “just ignore everything in non-listed directories”. But, in practice, copy-paste errors, renamings and partial updates do happen. Having more sanity checks is always useful.