Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/dune_rules/modules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,9 @@ module Group = struct
fun acc modules m -> loop acc modules (Module.path m)
;;

let parents (t : t) m = parents_modules [ t ] t.modules m
(* [parents acc modules m] returns [acc] followed by all parent groups of
module [m], ordered from innermost to outermost parent. *)
let parents (t : t) m = parents_modules [ t ] t.modules m |> List.rev

module Memo_traversals = struct
let rec parallel_map ({ alias; modules; name = _ } as t) ~f =
Expand Down Expand Up @@ -485,7 +487,10 @@ module Group = struct
Ok (if Module_name.equal name (Module.name li) then [ li ] else [])
| _ ->
(* TODO don't recompute this *)
let parents = parents t of_ |> List.map ~f:(fun g -> g.modules, Some g.name) in
let parents =
parents_modules [ t ] t.modules of_
|> List.map ~f:(fun g -> g.modules, Some g.name)
in
Find_dep.find_dep_of_parents parents name
;;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Testing the bootstrap of a wrapped include subdirs qualified.
There is ambiguity between the two different foo modules.
We show that the behaviour is correct in the bootstrap process:
it picks up the closest one.

$ . ./helpers.sh
$ mkdir a

$ cat > a/foo.ml << EOF
> let msg = "shouldn't be printed"
> EOF

$ mkdir a/bar
$ cat > a/bar/foo.ml << EOF
> let msg = "the correct module"
> EOF

$ cat > a/bar/baz.ml << EOF
> let exported = Foo.msg ^ "!"
> EOF

$ cat > a/dune <<EOF
> (library
> (name a))
> (include_subdirs qualified)
> EOF

$ create_dune a <<EOF
> module M1 = A.Bar.Baz
> let () = Printf.printf "Hello from %s\n" M1.exported
> EOF
ocamlc -output-complete-exe -intf-suffix .dummy -g -o .duneboot.exe -I boot -I +unix unix.cma boot/types.ml boot/libs.ml boot/duneboot.ml
./.duneboot.exe
Hello from the correct module!
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
There is ambiguity between the two different foo modules.
The behaviour is now correct both in the bootstrap process, and in dune.
It picks up the closest one.

$ echo "(lang dune 3.21)" > dune-project
$ cat > dune << EOF
> (include_subdirs qualified)
> (executable
> (name main))
> EOF

$ cat > main.ml << EOF
> let () = print_endline Bar.Baz.exported
> EOF

$ cat > foo.ml << EOF
> let msg = "Failure"
> EOF

$ mkdir bar
$ cat > bar/foo.ml << EOF
> let msg = "Success"
> EOF

$ cat > bar/baz.ml << EOF
> let exported = Foo.msg ^ "!"
> EOF

This is now fixed.
$ dune exec ./main.exe
Success!
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
(S $TESTCASE_ROOT/groupintf)
(S $TESTCASE_ROOT/utils)
(FLG (-w @[email protected]@30..39@[email protected]@[email protected]@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -g))
(FLG (-open Foo__Groupintf__ -open Foo))
(FLG (-open Foo -open Foo__Groupintf__))
(UNIT_NAME foo__Groupintf__Calc))
Calc: _build/default/groupintf/calc.ml
((INDEX $TESTCASE_ROOT/_build/default/.foo.objs/cctx.ocaml-index)
Expand All @@ -109,7 +109,7 @@
(S $TESTCASE_ROOT/groupintf)
(S $TESTCASE_ROOT/utils)
(FLG (-w @[email protected]@30..39@[email protected]@[email protected]@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -g))
(FLG (-open Foo__Groupintf__ -open Foo))
(FLG (-open Foo -open Foo__Groupintf__))
(UNIT_NAME foo__Groupintf__Calc))
Groupintf: _build/default/groupintf/groupintf
((INDEX $TESTCASE_ROOT/_build/default/.foo.objs/cctx.ocaml-index)
Expand All @@ -121,7 +121,7 @@
(S $TESTCASE_ROOT/groupintf)
(S $TESTCASE_ROOT/utils)
(FLG (-w @[email protected]@30..39@[email protected]@[email protected]@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -g))
(FLG (-open Foo__Groupintf__ -open Foo))
(FLG (-open Foo -open Foo__Groupintf__))
(UNIT_NAME foo__Groupintf))
Groupintf: _build/default/groupintf/groupintf.ml
((INDEX $TESTCASE_ROOT/_build/default/.foo.objs/cctx.ocaml-index)
Expand All @@ -133,7 +133,7 @@
(S $TESTCASE_ROOT/groupintf)
(S $TESTCASE_ROOT/utils)
(FLG (-w @[email protected]@30..39@[email protected]@[email protected]@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -g))
(FLG (-open Foo__Groupintf__ -open Foo))
(FLG (-open Foo -open Foo__Groupintf__))
(UNIT_NAME foo__Groupintf))
Main: _build/default/main
((INDEX $TESTCASE_ROOT/_build/default/.foo.objs/cctx.ocaml-index)
Expand Down Expand Up @@ -169,7 +169,7 @@
(S $TESTCASE_ROOT/groupintf)
(S $TESTCASE_ROOT/utils)
(FLG (-w @[email protected]@30..39@[email protected]@[email protected]@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -g))
(FLG (-open Foo__Utils -open Foo))
(FLG (-open Foo -open Foo__Utils))
(UNIT_NAME foo__Utils__Calc))
Calc: _build/default/utils/calc.ml
((INDEX $TESTCASE_ROOT/_build/default/.foo.objs/cctx.ocaml-index)
Expand All @@ -181,6 +181,6 @@
(S $TESTCASE_ROOT/groupintf)
(S $TESTCASE_ROOT/utils)
(FLG (-w @[email protected]@30..39@[email protected]@[email protected]@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -g))
(FLG (-open Foo__Utils -open Foo))
(FLG (-open Foo -open Foo__Utils))
(UNIT_NAME foo__Utils__Calc))
$ dune ocaml merlin dump-config utils
Loading