Skip to content

Using (select) with same named library and module give duplicates #6726

@jonahbeckford

Description

@jonahbeckford

Expected Behavior

When compiling ocaml-crunch.3.3.1 with a recent trunk commit of Dune, I expect to see ocaml-crunch compile successfully.

In particular https://github.com/mirage/ocaml-crunch/blob/bd4f0195b35c602b8b83886bc8731e649b1e3f9c/src/dune should build:

(library
 ; Dummy library to detect the OCaml version
 (name realpath)
 (modules)
 (enabled_if
  (< %{ocaml_version} "4.13")))

(library
 (name crunch)
 (wrapped false)
 (synopsis "Compile static files into a static filesystem")
 (modules crunch)
 (public_name crunch)
 (libraries unix ptime)
 (flags :standard -safe-string))

(executable
 (name main)
 (modules main realpath)
 (public_name ocaml-crunch)
 (libraries
  cmdliner
  crunch
  (select
   realpath.ml
   from
   (realpath -> realpath.pre_413.ml)
   (-> realpath.unix.ml))))

(There is a smaller, minimal test case in the reproduction section)

Actual Behavior

Instead I see:

[crunch-4168-afad7d.out] File "src/dune", line 1, characters 0-0:
[crunch-4168-afad7d.out] Error: Module "Realpath" is used in several stanzas:
[crunch-4168-afad7d.out] - src/dune:1
[crunch-4168-afad7d.out] - src/dune:17
[crunch-4168-afad7d.out] To fix this error, you must specify an explicit "modules" field in every
[crunch-4168-afad7d.out] library, executable, and executables stanzas in this dune file. Note that
[crunch-4168-afad7d.out] each module cannot appear in more than one "modules" field - it must belong
[crunch-4168-afad7d.out] to a single library or executable.

Reproduction

  • PR with a reproducing test:

#6725

Specifications

  • Version of dune (output of dune --version):
    n/a (it is a trunk version a237caa)

  • Version of ocaml (output of ocamlc --version)
    4.14.0

  • Operating system (distribution and version):
    Windows 11 22H2 22621.963

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions