From b39ad6dbeead38155b6b42a69709b14c051ae848 Mon Sep 17 00:00:00 2001 From: Ulysse <5031221+voodoos@users.noreply.github.com> Date: Fri, 11 Oct 2024 07:43:49 +0200 Subject: [PATCH] Use new hidden deps Merlin support for handling implicit-transitive-deps false (#10535) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ulysse GĂ©rard --- doc/changes/10535.md | 2 + src/dune_rules/exe_rules.ml | 6 +- src/dune_rules/lib_rules.ml | 6 +- src/dune_rules/melange/melange_rules.ml | 5 +- src/dune_rules/merlin/merlin.ml | 141 +++++++++++++----- src/dune_rules/merlin/merlin.mli | 4 +- test/blackbox-tests/test-cases/merlin/dune | 10 ++ .../implicit-transitive-deps-5.2.t/bin/dune | 4 + .../bin/main.ml | 1 + .../dune-project | 2 + .../implicit-transitive-deps-5.2.t/run.t | 44 ++++++ .../src/lib1/dune | 3 + .../src/lib1/lib1.ml | 1 + .../src/lib2/dune | 3 + .../src/lib2/lib2.ml | 3 + .../implicit-transitive-deps.t/bin/main.ml | 2 +- .../implicit-transitive-deps.t/dune-project | 4 +- .../merlin/implicit-transitive-deps.t/run.t | 19 ++- test/expect-tests/persistent_tests.ml | 4 +- 19 files changed, 203 insertions(+), 61 deletions(-) create mode 100644 doc/changes/10535.md create mode 100644 test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/bin/dune create mode 100644 test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/bin/main.ml create mode 100644 test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/dune-project create mode 100644 test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/run.t create mode 100644 test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib1/dune create mode 100644 test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib1/lib1.ml create mode 100644 test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib2/dune create mode 100644 test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib2/lib2.ml diff --git a/doc/changes/10535.md b/doc/changes/10535.md new file mode 100644 index 00000000000..7306c8a8459 --- /dev/null +++ b/doc/changes/10535.md @@ -0,0 +1,2 @@ +- Make Merlin/OCaml-LSP aware of "hidden" dependencies used by + `(implicit_transitive_deps false)` via the `-H` compiler flag. (#10535, @voodoos) diff --git a/src/dune_rules/exe_rules.ml b/src/dune_rules/exe_rules.ml index edc6a78487d..c3de011f3af 100644 --- a/src/dune_rules/exe_rules.ml +++ b/src/dune_rules/exe_rules.ml @@ -197,7 +197,7 @@ let executables_rules let lib_config = ocaml.lib_config in let stdlib_dir = lib_config.stdlib_dir in let* requires_compile = Compilation_context.requires_compile cctx in - let* requires_link = Compilation_context.requires_link cctx in + let* requires_hidden = Compilation_context.requires_hidden cctx in let* dep_graphs = (* Building an archive for foreign stubs, we link the corresponding object files directly to improve perf. *) @@ -281,11 +281,11 @@ let executables_rules in ( cctx , Merlin.make - ~requires:requires_link + ~requires_compile + ~requires_hidden ~stdlib_dir ~flags ~modules - ~source_dirs:Path.Source.Set.empty ~libname:None ~obj_dir ~preprocess: diff --git a/src/dune_rules/lib_rules.ml b/src/dune_rules/lib_rules.ml index 5db0c2b7154..9893e17dd8f 100644 --- a/src/dune_rules/lib_rules.ml +++ b/src/dune_rules/lib_rules.ml @@ -572,7 +572,7 @@ let library_rules let scope = Compilation_context.scope cctx in let* requires_compile = Compilation_context.requires_compile cctx in let ocaml = Compilation_context.ocaml cctx in - let* requires_link = Compilation_context.requires_link cctx in + let* requires_hidden = Compilation_context.requires_hidden cctx in let stdlib_dir = ocaml.lib_config.stdlib_dir in let top_sorted_modules = let impl_only = Modules.With_vlib.impl_only modules in @@ -628,11 +628,11 @@ let library_rules in ( cctx , Merlin.make - ~requires:requires_link + ~requires_compile + ~requires_hidden ~stdlib_dir ~flags ~modules - ~source_dirs:Path.Source.Set.empty ~preprocess:(Preprocess.Per_module.without_instrumentation lib.buildable.preprocess) ~libname:(Some (snd lib.name)) ~obj_dir diff --git a/src/dune_rules/melange/melange_rules.ml b/src/dune_rules/melange/melange_rules.ml index f3a456459a6..8f75c43708b 100644 --- a/src/dune_rules/melange/melange_rules.ml +++ b/src/dune_rules/melange/melange_rules.ml @@ -326,6 +326,7 @@ let setup_emit_cmj_rules in let* () = Module_compilation.build_all cctx in let* requires_compile = Compilation_context.requires_compile cctx in + let* requires_hidden = Compilation_context.requires_hidden cctx in let stdlib_dir = (Compilation_context.ocaml cctx).lib_config.stdlib_dir in let+ () = let emit_and_libs_deps = @@ -354,11 +355,11 @@ let setup_emit_cmj_rules in ( cctx , Merlin.make - ~requires:requires_compile + ~requires_compile + ~requires_hidden ~stdlib_dir ~flags ~modules - ~source_dirs:Path.Source.Set.empty ~libname:None ~preprocess:(Preprocess.Per_module.without_instrumentation mel.preprocess) ~obj_dir diff --git a/src/dune_rules/merlin/merlin.ml b/src/dune_rules/merlin/merlin.ml index 742ba34570a..dc7641b2a80 100644 --- a/src/dune_rules/merlin/merlin.ml +++ b/src/dune_rules/merlin/merlin.ml @@ -51,13 +51,24 @@ module Processed = struct ; source_root : Path.t ; obj_dirs : Path.Set.t ; src_dirs : Path.Set.t + ; hidden_obj_dirs : Path.Set.t + ; hidden_src_dirs : Path.Set.t ; flags : string list ; extensions : string option Ml_kind.Dict.t list ; indexes : Path.t list } let dyn_of_config - { stdlib_dir; source_root; obj_dirs; src_dirs; flags; extensions; indexes } + { stdlib_dir + ; source_root + ; obj_dirs + ; src_dirs + ; hidden_obj_dirs + ; hidden_src_dirs + ; flags + ; extensions + ; indexes + } = let open Dyn in record @@ -65,6 +76,8 @@ module Processed = struct ; "source_root", Path.to_dyn source_root ; "obj_dirs", Path.Set.to_dyn obj_dirs ; "src_dirs", Path.Set.to_dyn src_dirs + ; "hidden_obj_dirs", Path.Set.to_dyn hidden_obj_dirs + ; "hidden_src_dirs", Path.Set.to_dyn hidden_src_dirs ; "flags", list string flags ; "extensions", list (Ml_kind.Dict.to_dyn (Dyn.option string)) extensions ; "indexes", list Path.to_dyn indexes @@ -106,7 +119,7 @@ module Processed = struct type nonrec t = t let name = "merlin-conf" - let version = 5 + let version = 6 let to_dyn _ = Dyn.String "Use [dune ocaml dump-dot-merlin] instead" let test_example () = @@ -115,6 +128,8 @@ module Processed = struct ; source_root = Path.Source.root |> Path.source ; obj_dirs = Path.Set.empty ; src_dirs = Path.Set.empty + ; hidden_obj_dirs = Path.Set.empty + ; hidden_src_dirs = Path.Set.empty ; flags = [ "-x" ] ; extensions = [ { Ml_kind.Dict.intf = None; impl = Some "ext" } ] ; indexes = [] @@ -162,7 +177,16 @@ module Processed = struct ~opens ~pp ~reader - { stdlib_dir; source_root; obj_dirs; src_dirs; flags; extensions; indexes } + { stdlib_dir + ; source_root + ; obj_dirs + ; src_dirs + ; hidden_obj_dirs + ; hidden_src_dirs + ; flags + ; extensions + ; indexes + } = let make_directive tag value = Sexp.List [ Atom tag; value ] in let make_directive_of_path tag path = @@ -178,6 +202,12 @@ module Processed = struct let exclude_query_dir = [ Sexp.List [ Atom "EXCLUDE_QUERY_DIR" ] ] in let obj_dirs = Path.Set.to_list_map obj_dirs ~f:(make_directive_of_path "B") in let src_dirs = Path.Set.to_list_map src_dirs ~f:(make_directive_of_path "S") in + let hidden_obj_dirs = + Path.Set.to_list_map hidden_obj_dirs ~f:(make_directive_of_path "BH") + in + let hidden_src_dirs = + Path.Set.to_list_map hidden_src_dirs ~f:(make_directive_of_path "SH") + in let flags = let flags = match flags with @@ -222,6 +252,8 @@ module Processed = struct ; exclude_query_dir ; obj_dirs ; src_dirs + ; hidden_obj_dirs + ; hidden_src_dirs ; flags ; unit_name ; suffixes @@ -249,6 +281,8 @@ module Processed = struct flags obj_dirs src_dirs + hidden_obj_dirs + hidden_src_dirs extensions indexes = @@ -261,6 +295,8 @@ module Processed = struct printf "SOURCE_ROOT %s\n" (serialize_path source_root); Path.Set.iter obj_dirs ~f:(fun p -> printf "B %s\n" (serialize_path p)); Path.Set.iter src_dirs ~f:(fun p -> printf "S %s\n" (serialize_path p)); + Path.Set.iter hidden_obj_dirs ~f:(fun p -> printf "BH %s\n" (serialize_path p)); + Path.Set.iter hidden_src_dirs ~f:(fun p -> printf "SH %s\n" (serialize_path p)); List.iter indexes ~f:(fun p -> printf "INDEX %s\n" (serialize_path p)); List.iter extensions ~f:(fun x -> Option.iter (get_ext x) ~f:(fun (impl, intf) -> @@ -335,7 +371,15 @@ module Processed = struct | Error msg -> Printf.eprintf "%s\n" msg | Ok [] -> Printf.eprintf "No merlin configuration found.\n" | Ok (init :: tl) -> - let pp_configs, obj_dirs, src_dirs, flags, extensions, indexes = + let ( pp_configs + , obj_dirs + , src_dirs + , hidden_obj_dirs + , hidden_src_dirs + , flags + , extensions + , indexes ) + = (* We merge what is easy to merge and ignore the rest *) List.fold_left tl @@ -343,12 +387,21 @@ module Processed = struct ( [ init.pp_config ] , init.config.obj_dirs , init.config.src_dirs + , init.config.hidden_obj_dirs + , init.config.hidden_src_dirs , [ init.config.flags ] , init.config.extensions , init.config.indexes ) ~f: (fun - (acc_pp, acc_obj, acc_src, acc_flags, acc_ext, acc_indexes) + ( acc_pp + , acc_obj + , acc_src + , acc_hidden_obj + , acc_hidden_src + , acc_flags + , acc_ext + , acc_indexes ) { per_file_config = _ ; pp_config ; config = @@ -356,6 +409,8 @@ module Processed = struct ; source_root = _ ; obj_dirs ; src_dirs + ; hidden_obj_dirs + ; hidden_src_dirs ; flags ; extensions ; indexes @@ -365,6 +420,8 @@ module Processed = struct ( pp_config :: acc_pp , Path.Set.union acc_obj obj_dirs , Path.Set.union acc_src src_dirs + , Path.Set.union acc_hidden_obj hidden_obj_dirs + , Path.Set.union acc_hidden_src hidden_src_dirs , flags :: acc_flags , extensions @ acc_ext , indexes @ acc_indexes )) @@ -378,6 +435,8 @@ module Processed = struct flags obj_dirs src_dirs + hidden_obj_dirs + hidden_src_dirs extensions indexes) ;; @@ -399,12 +458,12 @@ module Unprocessed = struct Processed.t] *) type config = { stdlib_dir : Path.t - ; requires : Lib.Set.t + ; requires_compile : Lib.t list Resolve.t + ; requires_hidden : Lib.t list Resolve.t ; flags : string list Action_builder.t ; preprocess : Preprocess.Without_instrumentation.t Preprocess.t Module_name.Per_item.t ; libname : Lib_name.Local.t option - ; source_dirs : Path.Source.Set.t ; objs_dirs : Path.Set.t ; extensions : string option Ml_kind.Dict.t list ; readers : string list String.Map.t @@ -418,12 +477,12 @@ module Unprocessed = struct } let make - ~requires + ~requires_compile + ~requires_hidden ~stdlib_dir ~flags ~preprocess ~libname - ~source_dirs ~modules ~obj_dir ~dialects @@ -437,11 +496,6 @@ module Unprocessed = struct | `Melange_emit -> Melange | `Lib (m : Lib_mode.Map.Set.t) -> Lib_mode.Map.Set.for_merlin m in - let requires = - match Resolve.peek requires with - | Ok l -> Lib.Set.of_list l - | Error () -> Lib.Set.empty - in let objs_dirs = Path.Set.singleton @@ obj_dir_of_lib `Private mode (Obj_dir.of_local obj_dir) in @@ -450,11 +504,11 @@ module Unprocessed = struct let config = { stdlib_dir ; mode - ; requires + ; requires_compile + ; requires_hidden ; flags ; preprocess ; libname - ; source_dirs ; objs_dirs ; extensions ; readers @@ -556,6 +610,23 @@ module Unprocessed = struct ~f:(pp_flags ctx ~expander t.config.libname) ;; + let add_lib_dirs sctx mode libs = + Action_builder.of_memo + (let open Memo.O in + Memo.parallel_map libs ~f:(fun lib -> + let+ dirs = src_dirs sctx lib in + lib, dirs) + >>| List.fold_left + ~init:(Path.Set.empty, Path.Set.empty) + ~f:(fun (src_dirs, obj_dirs) (lib, more_src_dirs) -> + ( Path.Set.union src_dirs more_src_dirs + , let public_cmi_dir = + let info = Lib.info lib in + obj_dir_of_lib `Public mode (Lib_info.obj_dir info) + in + Path.Set.add obj_dirs public_cmi_dir ))) + ;; + let process ({ modules ; ident = _ @@ -565,8 +636,8 @@ module Unprocessed = struct ; readers ; flags ; objs_dirs - ; source_dirs - ; requires + ; requires_compile + ; requires_hidden ; preprocess = _ ; libname = _ ; mode @@ -591,9 +662,11 @@ module Unprocessed = struct | [] -> None | stdlib_dir :: _ -> Some stdlib_dir) in - let* requires = + let requires_compile = Resolve.peek requires_compile |> Result.value ~default:[] in + let requires_hidden = Resolve.peek requires_hidden |> Result.value ~default:[] in + let* requires_compile, requires_hidden = match t.config.mode with - | Ocaml _ -> Action_builder.return requires + | Ocaml _ -> Action_builder.return (requires_compile, requires_hidden) | Melange -> Action_builder.of_memo (let open Memo.O in @@ -612,34 +685,24 @@ module Unprocessed = struct | Ok libs -> libs | Error _ -> [] in - Lib.Set.union requires (Lib.Set.of_list libs) - | None -> Memo.return requires) + List.concat [ requires_compile; libs ], requires_hidden + | None -> Memo.return (requires_compile, requires_hidden)) in let+ flags = flags - and+ src_dirs, obj_dirs = - Action_builder.of_memo - (let open Memo.O in - Memo.parallel_map (Lib.Set.to_list requires) ~f:(fun lib -> - let+ dirs = src_dirs sctx lib in - lib, dirs) - >>| List.fold_left - ~init:(Path.set_of_source_paths source_dirs, objs_dirs) - ~f:(fun (src_dirs, obj_dirs) (lib, more_src_dirs) -> - ( Path.Set.union src_dirs more_src_dirs - , let public_cmi_dir = - let info = Lib.info lib in - obj_dir_of_lib `Public mode (Lib_info.obj_dir info) - in - Path.Set.add obj_dirs public_cmi_dir ))) - and+ indexes = Action_builder.of_memo (Ocaml_index.context_indexes sctx) in + and+ indexes = Action_builder.of_memo (Ocaml_index.context_indexes sctx) + and+ deps_src_dirs, deps_obj_dirs = add_lib_dirs sctx mode requires_compile + and+ hidden_src_dirs, hidden_obj_dirs = add_lib_dirs sctx mode requires_hidden in let src_dirs = - Path.Set.union src_dirs (Path.Set.of_list_map ~f:Path.source more_src_dirs) + Path.Set.of_list_map ~f:Path.source more_src_dirs |> Path.Set.union deps_src_dirs in + let obj_dirs = Path.Set.union deps_obj_dirs objs_dirs in let source_root = Path.Source.root |> Path.source in { Processed.stdlib_dir ; source_root ; src_dirs ; obj_dirs + ; hidden_src_dirs + ; hidden_obj_dirs ; flags ; extensions ; indexes diff --git a/src/dune_rules/merlin/merlin.mli b/src/dune_rules/merlin/merlin.mli index 57f92caa22c..f063f1f8397 100644 --- a/src/dune_rules/merlin/merlin.mli +++ b/src/dune_rules/merlin/merlin.mli @@ -41,12 +41,12 @@ module Processed : sig end val make - : requires:Lib.t list Resolve.t + : requires_compile:Lib.t list Resolve.t + -> requires_hidden:Lib.t list Resolve.t -> stdlib_dir:Path.t -> flags:Ocaml_flags.t -> preprocess:Preprocess.Without_instrumentation.t Preprocess.t Module_name.Per_item.t -> libname:Lib_name.Local.t option - -> source_dirs:Path.Source.Set.t -> modules:Modules.With_vlib.t -> obj_dir:Path.Build.t Obj_dir.t -> dialects:Dialect.DB.t diff --git a/test/blackbox-tests/test-cases/merlin/dune b/test/blackbox-tests/test-cases/merlin/dune index bd374865ffd..5dc72a5560e 100644 --- a/test/blackbox-tests/test-cases/merlin/dune +++ b/test/blackbox-tests/test-cases/merlin/dune @@ -9,3 +9,13 @@ (cram (applies_to github4125) (deps %{bin:opam})) + +(cram + (applies_to implicit-transitive-deps) + (enabled_if + (< %{ocaml_version} 5.2))) + +(cram + (applies_to implicit-transitive-deps-5.2) + (enabled_if + (>= %{ocaml_version} 5.2))) diff --git a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/bin/dune b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/bin/dune new file mode 100644 index 00000000000..7f57e46dfb5 --- /dev/null +++ b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/bin/dune @@ -0,0 +1,4 @@ +(executable + (name main) + (flags :standard -w -34) + (libraries lib1)) diff --git a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/bin/main.ml b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/bin/main.ml new file mode 100644 index 00000000000..2f5fb3b592d --- /dev/null +++ b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/bin/main.ml @@ -0,0 +1 @@ +type t = Lib1.t \ No newline at end of file diff --git a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/dune-project b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/dune-project new file mode 100644 index 00000000000..fff9b78b842 --- /dev/null +++ b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/dune-project @@ -0,0 +1,2 @@ +(lang dune 3.17) +(implicit_transitive_deps false) diff --git a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/run.t b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/run.t new file mode 100644 index 00000000000..f103b7e807f --- /dev/null +++ b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/run.t @@ -0,0 +1,44 @@ + $ stdlib="$(ocamlc -where)" + $ export BUILD_PATH_PREFIX_MAP="/STDLIB=$stdlib:$BUILD_PATH_PREFIX_MAP" + + $ dune build @check + +Merlin must be able to locate the definitions of values coming from an +implicit transitive dependency, even when `implicit-transitive-dependency` is +set to `false`. They should be part of the source path returned by the +configuration. + +In this test the dependencies are as follow: +main -> lib1 -> lib2 -> stdlib + +When using OCaml >= 5.2 these hidden dependencies are passed to merlin using the +new `*H` directives. + $ FILE=$PWD/bin/main.ml + $ printf "(4:File%d:%s)" ${#FILE} $FILE | dune ocaml-merlin | + > sed -E "s/[[:digit:]]+:/\?:/g" | tr '(' '\n' | grep -E ":[BS]H?\?" + ?:B?:$TESTCASE_ROOT/_build/default/bin/.main.eobjs/byte) + ?:B?:$TESTCASE_ROOT/_build/default/src/lib1/.lib1.objs/byte) + ?:S?:$TESTCASE_ROOT/bin) + ?:S?:$TESTCASE_ROOT/src/lib1) + ?:BH?:/STDLIB/unix) + ?:BH?:$TESTCASE_ROOT/_build/default/src/lib2/.lib2.objs/byte) + ?:SH?:/STDLIB/unix) + ?:SH?:$TESTCASE_ROOT/src/lib2) + + $ FILE=$PWD/src/lib1/lib1.ml + $ printf "(4:File%d:%s)" ${#FILE} $FILE | dune ocaml-merlin | + > sed -E "s/[[:digit:]]+:/\?:/g" | tr '(' '\n' | grep -E ":[BS]H?\?" + ?:B?:/STDLIB/unix) + ?:B?:$TESTCASE_ROOT/_build/default/src/lib1/.lib1.objs/byte) + ?:B?:$TESTCASE_ROOT/_build/default/src/lib2/.lib2.objs/byte) + ?:S?:/STDLIB/unix) + ?:S?:$TESTCASE_ROOT/src/lib1) + ?:S?:$TESTCASE_ROOT/src/lib2) + + $ FILE=$PWD/src/lib2/lib2.ml + $ printf "(4:File%d:%s)" ${#FILE} $FILE | dune ocaml-merlin | + > sed -E "s/[[:digit:]]+:/\?:/g" | tr '(' '\n' | grep -E ":[BS]H?\?" + ?:B?:/STDLIB/unix) + ?:B?:$TESTCASE_ROOT/_build/default/src/lib2/.lib2.objs/byte) + ?:S?:/STDLIB/unix) + ?:S?:$TESTCASE_ROOT/src/lib2) diff --git a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib1/dune b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib1/dune new file mode 100644 index 00000000000..659f51cccfa --- /dev/null +++ b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib1/dune @@ -0,0 +1,3 @@ +(library + (name lib1) + (libraries lib2 unix)) diff --git a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib1/lib1.ml b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib1/lib1.ml new file mode 100644 index 00000000000..8b4941c18c6 --- /dev/null +++ b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib1/lib1.ml @@ -0,0 +1 @@ +include Lib2 diff --git a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib2/dune b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib2/dune new file mode 100644 index 00000000000..eba0287a9dd --- /dev/null +++ b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib2/dune @@ -0,0 +1,3 @@ +(library + (name lib2) + (libraries unix)) diff --git a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib2/lib2.ml b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib2/lib2.ml new file mode 100644 index 00000000000..e206be29b61 --- /dev/null +++ b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps-5.2.t/src/lib2/lib2.ml @@ -0,0 +1,3 @@ +type t = bool + +type r = Unix.error \ No newline at end of file diff --git a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps.t/bin/main.ml b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps.t/bin/main.ml index 2f5fb3b592d..cf8e7bb1fbb 100644 --- a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps.t/bin/main.ml +++ b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps.t/bin/main.ml @@ -1 +1 @@ -type t = Lib1.t \ No newline at end of file +type _t = Lib1.t diff --git a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps.t/dune-project b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps.t/dune-project index f390b5360ef..fff9b78b842 100644 --- a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps.t/dune-project +++ b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps.t/dune-project @@ -1,2 +1,2 @@ -(lang dune 2.0) -(implicit_transitive_deps false) \ No newline at end of file +(lang dune 3.17) +(implicit_transitive_deps false) diff --git a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps.t/run.t b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps.t/run.t index 6673d7da409..a38c92adc49 100644 --- a/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps.t/run.t +++ b/test/blackbox-tests/test-cases/merlin/implicit-transitive-deps.t/run.t @@ -3,7 +3,7 @@ $ dune build @check -FIXME: Merlin must be able to locate the definitions of values coming from an +Merlin must be able to locate the definitions of values coming from an implicit transitive dependency, even when `implicit-transitive-dependency` is set to `false`. They should be part of the source path returned by the configuration. @@ -11,23 +11,28 @@ configuration. In this test the dependencies are as follow: main -> lib1 -> lib2 -> stdlib +When using OCaml < 5.2 there is no proper way to provide that information to +Merlin. $ FILE=$PWD/bin/main.ml $ printf "(4:File%d:%s)" ${#FILE} $FILE | dune ocaml-merlin | - > sed -E "s/[[:digit:]]+:/\?:/g" | tr '(' '\n' | grep ":S?" + > sed -E "s/[[:digit:]]+:/\?:/g" | tr '(' '\n' | grep -E ":[BS]H?\?" + ?:B?:$TESTCASE_ROOT/_build/default/bin/.main.eobjs/byte) + ?:B?:$TESTCASE_ROOT/_build/default/src/lib1/.lib1.objs/byte) ?:S?:$TESTCASE_ROOT/bin) ?:S?:$TESTCASE_ROOT/src/lib1) - ?:S?:$TESTCASE_ROOT/src/lib2) - ?:S?:$TESTCASE_ROOT/src/lib_dep) $ FILE=$PWD/src/lib1/lib1.ml $ printf "(4:File%d:%s)" ${#FILE} $FILE | dune ocaml-merlin | - > sed -E "s/[[:digit:]]+:/\?:/g" | tr '(' '\n' | grep ":S?" + > sed -E "s/[[:digit:]]+:/\?:/g" | tr '(' '\n' | grep -E ":[BS]H?\?" + ?:B?:$TESTCASE_ROOT/_build/default/src/lib1/.lib1.objs/byte) + ?:B?:$TESTCASE_ROOT/_build/default/src/lib2/.lib2.objs/byte) ?:S?:$TESTCASE_ROOT/src/lib1) ?:S?:$TESTCASE_ROOT/src/lib2) - ?:S?:$TESTCASE_ROOT/src/lib_dep) $ FILE=$PWD/src/lib2/lib2.ml $ printf "(4:File%d:%s)" ${#FILE} $FILE | dune ocaml-merlin | - > sed -E "s/[[:digit:]]+:/\?:/g" | tr '(' '\n' | grep ":S?" + > sed -E "s/[[:digit:]]+:/\?:/g" | tr '(' '\n' | grep -E ":[BS]H?\?" + ?:B?:$TESTCASE_ROOT/_build/default/src/lib2/.lib2.objs/byte) + ?:B?:$TESTCASE_ROOT/_build/default/src/lib_dep/.dep.objs/byte) ?:S?:$TESTCASE_ROOT/src/lib2) ?:S?:$TESTCASE_ROOT/src/lib_dep) diff --git a/test/expect-tests/persistent_tests.ml b/test/expect-tests/persistent_tests.ml index 7f386431cc6..159f9993c1a 100644 --- a/test/expect-tests/persistent_tests.ml +++ b/test/expect-tests/persistent_tests.ml @@ -43,8 +43,8 @@ let%expect_test "persistent digests" = 7dac5b11f6f654bb6f230392493b363f --- - merlin-conf version 5 - 49e3a1010b7218f5b229d98991d6d11d + merlin-conf version 6 + 880477921df9a8915d57c0e8bdfb2fc1 --- INCREMENTAL-DB version 5