merlin icon indicating copy to clipboard operation
merlin copied to clipboard

Duplicated open flags revealing a dunolint bug

Open mbarbin opened this issue 9 months ago • 0 comments

Hi,

Out of the blue I was trying dunolint on the merlin project. Namely, running:

$ dunolint lint

at the root of the project.

This revealed some bug in dunolint, which I will be working on.

There may be something for your consideration in the condition that triggers this bug. This is about -open flags that are written more than once, such as these two cases from the merlin code base:

  • In src/frontend/dune:
(flags
  :standard
  -open Ocaml_utils
  -open Ocaml_parsing
  -open Ocaml_typing
  -open Merlin_kernel
  -open Merlin_specific
  -open Merlin_utils
  -open Merlin_specific
  -open Merlin_analysis
  -open Merlin_kernel)

Possibly duplicated: Merlin_kernel, Merlin_specific.

  • In src/ocaml/merlin_specific/dune:
  (flags
   :standard
   -open Ocaml_utils
   -open Ocaml_parsing
   -open Ocaml_preprocess
   -open Ocaml_typing
   -open Ocaml_preprocess
   -open Merlin_utils)

Possibly duplicated: Ocaml_preprocess

I don't think this is likely, but in theory, perhaps there is e.g. a module named Ocaml_preprocess in Ocaml_typing that would be different from the first Ocaml_preprocess, so if this sequence of open was located in an ml file, I'd say it is not safe to remove dups without further analysis

open Ocaml_preprocess
open Ocaml_typing
open Ocaml_preprocess

However for the flags -open given as flags via dune, I am not sure whether they can refer to module introduced by module open with a previous -open flag.. Anyways, I think in this case, these are likely dups. There is no incident for this, (and again, this allowed me to find a bug in dunolint, so great!) but I just thought I'd add this note in case you want to remove them.

mbarbin avatar Mar 17 '25 10:03 mbarbin