This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,46 @@
Private libraries using the same library name, in the same context, defined in
the same folder. One of them is unavailable because it's `(optional)` and a
dependency is missing.
$ cat > dune-project << EOF
> (lang dune 3.13)
> EOF
$ cat > dune << EOF
> (library
> (name foo)
> (libraries xxx)
> (optional))
> (library
> (name foo))
> EOF
$ cat > foo.ml << EOF
> let x = "hello"
> EOF
Without any consumers of the libraries
$ dune build
With some consumer of the library
$ cat > dune << EOF
> (library
> (name foo)
> (modules foo)
> (libraries xxx)
> (optional))
> (library
> (modules foo)
> (name foo))
> (executable
> (name main)
> (modules main)
> (libraries foo))
> EOF
$ cat > main.ml <<EOF
> let () = print_endline Foo.x
> EOF
$ dune build

View file

@ -0,0 +1,50 @@
Private libraries using the same library name, in the same context, defined in
the same folder.
$ cat > dune-project << EOF
> (lang dune 3.13)
> EOF
$ cat > dune << EOF
> (library
> (name foo)
> (modules))
> (library
> (name foo)
> (modules))
> EOF
Without any consumers of the libraries
$ dune build
File "dune", line 5, characters 7-10:
5 | (name foo)
^^^
Error: Library "foo" appears for the second time in this directory
[1]
With some consumer of the library
$ cat > dune << EOF
> (library
> (name foo)
> (modules))
> (library
> (name foo)
> (modules))
> (executable
> (name main)
> (modules main)
> (libraries foo))
> EOF
$ cat > main.ml <<EOF
> let () = Foo.x
> EOF
$ dune build
File "dune", line 5, characters 7-10:
5 | (name foo)
^^^
Error: Library "foo" appears for the second time in this directory
[1]

View file

@ -0,0 +1,42 @@
Private libraries using the same library name, in the same context, defined in
different folders.
$ mkdir -p a b
$ cat > dune-project << EOF
> (lang dune 3.13)
> EOF
$ cat > a/dune << EOF
> (library
> (name foo))
> EOF
$ cat > b/dune << EOF
> (library
> (name foo))
> EOF
Without any consumers of the libraries (both are built in separate folders)
$ dune build a/foo.cma b/foo.cma
With some consumer of the library
$ cat > dune << EOF
> (executable
> (name main)
> (libraries foo))
> EOF
$ cat > main.ml <<EOF
> let () = Foo.x
> EOF
$ dune build
File "a/dune", lines 1-2, characters 0-21:
1 | (library
2 | (name foo))
Error: Library with name "foo" is already defined in b/dune:1. Either change
one of the names, or enable them conditionally using the 'enabled_if' field.
[1]

View file

@ -0,0 +1,42 @@
Public libraries using the same library name, in the same context, defined in
the same folder.
$ cat > dune-project << EOF
> (lang dune 3.13)
> (package (name bar) (allow_empty))
> (package (name baz) (allow_empty))
> EOF
$ cat > dune << EOF
> (library
> (name foo)
> (public_name bar.foo))
> (library
> (name foo)
> (public_name baz.foo))
> EOF
Without any consumers of the libraries
$ dune build
File "dune", line 5, characters 7-10:
5 | (name foo)
^^^
Error: Library "foo" appears for the second time in this directory
[1]
$ rm dune
$ mkdir baz bar
$ cat > bar/dune << EOF
> (library
> (name foo)
> (public_name bar.foo))
> EOF
$ cat > baz/dune << EOF
> (library
> (name foo)
> (public_name baz.foo))
> EOF
$ dune build

View file

@ -0,0 +1,54 @@
Public libraries using the same library name, in the same context, defined in
the same folder.
$ cat > dune-project << EOF
> (lang dune 3.13)
> (package (name bar) (allow_empty))
> (package (name baz) (allow_empty))
> EOF
$ cat > dune << EOF
> (library
> (name foo)
> (public_name bar.foo))
> (library
> (name foo)
> (public_name baz.foo))
> EOF
Without any consumers of the libraries
$ dune build
File "dune", line 5, characters 7-10:
5 | (name foo)
^^^
Error: Library "foo" appears for the second time in this directory
[1]
With some consumer
$ cat > dune << EOF
> (library
> (name foo)
> (modules)
> (public_name bar.foo))
> (library
> (name foo)
> (modules)
> (public_name baz.foo))
> (executable
> (name main)
> (modules main)
> (libraries foo))
> EOF
$ cat > main.ml <<EOF
> let () = Foo.x
> EOF
$ dune build
File "dune", line 6, characters 7-10:
6 | (name foo)
^^^
Error: Library "foo" appears for the second time in this directory
[1]

View file

@ -0,0 +1,53 @@
Public libraries using the same library name, in the same context, defined in
the same folder.
$ mkdir -p a b
$ cat > dune-project << EOF
> (lang dune 3.13)
> (package (name bar) (allow_empty))
> EOF
$ cat > a/dune << EOF
> (library
> (name foo)
> (public_name bar.foo))
> (library
> (name bar)
> (public_name bar.foo))
> EOF
Without any consumers of the libraries
$ dune build
File "a/dune", lines 1-3, characters 0-44:
1 | (library
2 | (name foo)
3 | (public_name bar.foo))
Error: Public library bar.foo is defined twice:
- a/dune:4
- a/dune:1
[1]
With some consumer
$ cat > dune << EOF
> (executable
> (name main)
> (libraries foo))
> EOF
$ cat > main.ml <<EOF
> let () = Foo.x
> EOF
$ dune build
File "a/dune", lines 1-3, characters 0-44:
1 | (library
2 | (name foo)
3 | (public_name bar.foo))
Error: Public library bar.foo is defined twice:
- a/dune:4
- a/dune:1
[1]

View file

@ -0,0 +1,55 @@
Public libraries using the same library name, in the same context, defined in
different folders.
$ mkdir -p a b
$ cat > dune-project << EOF
> (lang dune 3.13)
> (package (name bar) (allow_empty))
> EOF
$ cat > a/dune << EOF
> (library
> (name foo)
> (public_name bar.foo))
> EOF
$ cat > b/dune << EOF
> (library
> (name bar)
> (public_name bar.foo))
> EOF
Without any consumers of the libraries
$ dune build
File "b/dune", lines 1-3, characters 0-44:
1 | (library
2 | (name bar)
3 | (public_name bar.foo))
Error: Public library bar.foo is defined twice:
- a/dune:1
- b/dune:1
[1]
With some consumer
$ cat > dune << EOF
> (executable
> (name main)
> (libraries foo))
> EOF
$ cat > main.ml <<EOF
> let () = Foo.x
> EOF
$ dune build
File "b/dune", lines 1-3, characters 0-44:
1 | (library
2 | (name bar)
3 | (public_name bar.foo))
Error: Public library bar.foo is defined twice:
- a/dune:1
- b/dune:1
[1]

View file

@ -0,0 +1,47 @@
Public libraries using the same library name, in the same context, defined in
different folders.
$ mkdir -p a b
$ cat > dune-project << EOF
> (lang dune 3.13)
> (package (name bar) (allow_empty))
> (package (name baz) (allow_empty))
> EOF
$ cat > a/dune << EOF
> (library
> (name foo)
> (public_name bar.foo))
> EOF
$ cat > b/dune << EOF
> (library
> (name foo)
> (public_name baz.foo))
> EOF
Without any consumers of the libraries
$ dune build
With some consumer
$ cat > dune << EOF
> (executable
> (name main)
> (libraries foo))
> EOF
$ cat > main.ml <<EOF
> let () = Foo.x
> EOF
$ dune build
File "a/dune", lines 1-3, characters 0-44:
1 | (library
2 | (name foo)
3 | (public_name bar.foo))
Error: Library with name "foo" is already defined in b/dune:1. Either change
one of the names, or enable them conditionally using the 'enabled_if' field.
[1]