You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the name of a test/executable in dune is the same as its library dependency, then ocamllsp will report Unbound module for that library, but dune build, dune runtest, or dune exec will work just fine.
Unfortunately, dune init project <name> uses a template with the same name for library and a test, which potentially can lead to confusion for newcomers.
Versions
ocaml 4.14.0
dune 3.3.1
ocamllsp 1.12.2
Tested in Visual Studio Code 1.69.0, using OCaml Platform v1.10.7.
Steps to Reproduce
1. Create a project from dune's default template
$ touch dune-workspace
$ dune init project example
Success: initialized project component named example
$ dune build
2. Create a module in the library
Put the following in example/lib/foo.ml:
letfoo()=
print_endline "Hello, world!"
3. Use the module in a test
Update example/test/dune to following:
(test
(name example)
(libraries example))
Update example/test/example.ml to following
let()=Example.Foo.foo ()
4. Run tests
$ dune runtest
Hello, world!
Bug?
Even though dune runtest works fine, ocamllsp reports Unbound module Example in example/test/example.ml:
Potential Workaround
Renaming the test to a different (i.e. test_example) by changing the name field in example/test/dune:
Problem
If the name of a test/executable in
dune
is the same as its library dependency, thenocamllsp
will reportUnbound module
for that library, butdune build
,dune runtest
, ordune exec
will work just fine.Unfortunately,
dune init project <name>
uses a template with the same name for library and a test, which potentially can lead to confusion for newcomers.Versions
Tested in Visual Studio Code
1.69.0
, using OCaml Platformv1.10.7
.Steps to Reproduce
1. Create a project from
dune
's default template2. Create a module in the library
Put the following in
example/lib/foo.ml
:3. Use the module in a test
Update
example/test/dune
to following:Update
example/test/example.ml
to following4. Run tests
$ dune runtest Hello, world!
Bug?
Even though
dune runtest
works fine,ocamllsp
reportsUnbound module Example
inexample/test/example.ml
:Potential Workaround
Renaming the test to a different (i.e.
test_example
) by changing thename
field inexample/test/dune
:and changing the name of the file
Fixes the problem.
The text was updated successfully, but these errors were encountered: