-
Notifications
You must be signed in to change notification settings - Fork 464
Description
We have a big project which looks like this one.
playground.zip
$ tree
.
├── dune-workspace
└── dune_exe
├── demo.opam
├── dune
├── dune-project
├── lib.ml
├── sub_exe
│ ├── dune
│ └── sub.ml
├── test.ml
└── test2.ml
While compiling with dune build @all, we obtain a .merlin file in dune_exe. This .merlin file contains -open Dune__exe. If I understand correctly, this module is generated by dune to wrap binaries. Unfortunately it seems to confuse merlin. Whenever we run a command with the "classic" merlin protocol in, we obtain an error because of a missing Dune__exe:
/home/louis/.opam/a/bin/ocamlmerlin single type-enclosing -protocol sexp -verbosity 0 -filename /long/path/to/a/file/test.ml -position 6:8 -index 0 < test.ml
((assoc) (class . "error") (value . "Unbound module Dune__exe") (notifications) (timing (assoc) (clock . 45) (cpu . 39) (query . 2) (pp . 0) (reader . 11) (ppx . 17) (typer . 10) (error . 0)))
In sub_exe/.merlin there is also -open Dune__exe, but no problem for merlin there.
It appears that merlin doesn't have this issue when used through ocaml-lsp, which is curious.
Unfortunately I couldn't manage to create a small example to replicate the error. I didn't find a way to trigger dune to generate the -open Dune__exe bit of the .merlin on a small case.
What I find suspicious is that dune generates only one Dune_exe module if I understand correctly (taken from our real repo, not the code shared above)
$ find ../_build/default/| rg une__exe\.c
../_build/default/some_project/sub_exe/.sub.eobjs/byte/dune__exe.cmi
../_build/default/some_project/sub_exe/.sub.eobjs/byte/dune__exe.cmt
../_build/default/some_project/sub_exe/.sub.eobjs/byte/dune__exe.cmo
And for the test binary, dune__exe is used as a prefix
$ find ../_build/default/| rg une__exe | rg test
../_build/default/some_project/.test.eobjs/byte/dune__exe__Test.cmt
../_build/default/some_project/.test.eobjs/byte/dune__exe__Test.cmo
../_build/default/some_project/.test.eobjs/byte/dune__exe__Test.cmi
../_build/default/some_project/.test.eobjs/dune__exe__Test.impl.all-deps
Specifications
- Version of
dune(output ofdune --version): 2.2.0 and 2.5.1 - Version of
ocaml(output ofocamlc --version): 4.09.0 - Operating system (distribution and version): debian 10