Dune Flag Propagation and OCaml -w Syntax: Overlapping Range Precedence
0 reputation · 05 Nov 2023, 15:48 UTC
When configuring OCaml compiler warnings through the -w flag, the interaction between Dune's build defaults and the compiler's own warning syntax creates ambiguity in complex projects. The -w flag accepts comma-separated warning numbers or ranges with +, -, or = prefixes, but the precise precedence rules remain unclear when a warning number falls inside both an enabled range and a later disabled range.
Dune automatically forwards -w settings from dune-project or dune files to the compiler, yet it may also apply its own default warning set. This raises uncertainty about whether Dune's defaults override, merge with, or defer to user-specified -w flags when overlapping ranges are present. The syntax itself has evolved across compiler releases, with older versions using a single prefix for the entire list and newer versions supporting per-warning prefixes, which complicates configuration portability.
Given that warning numbers shift between OCaml releases and broad ranges can silently suppress useful diagnostics, what is the authoritative precedence model when overlapping per-warning prefixes and ranges are combined? How should a project structure its -w specification in Dune to avoid conflicts with build-system defaults? Which compiler version boundaries define the supported syntax for per-warning prefixes versus whole-list prefixes?