From 735e95a3cfd20d27206e07fb72822b97d62ab562 Mon Sep 17 00:00:00 2001 From: Corentin De Souza <9597216+fantazio@users.noreply.github.com> Date: Mon, 26 Jan 2026 11:41:16 +0100 Subject: [PATCH 1/3] [examples][dune] add tests for the builder vs api pattern The new pattern was observed on Frama-C. It is described in `examples/using_dune/lib/values/builder_sig_api/README.md`. It uses a mix of module types, functors and includes dispatched in multiple files. It is not uncommon to use a `.ml` (without `.mli`) to expose module types and reuse these in other module's `.mli`. This pattern will need to be tested more specifically. The current report semantic for the values in module types is to not report them. --- check/classic/classic.ref | 9 +++++--- check/internal/internal.ref | 9 +++++--- check/threshold-1/threshold-1.exp | 2 ++ check/threshold-1/threshold-1.ref | 13 +++++++---- check/threshold-3-0.5/threshold-3-0.5.exp | 2 ++ check/threshold-3-0.5/threshold-3-0.5.ref | 22 +++++++++++++++---- .../use_unwrapped_lib/use_builder_sig_api.ml | 15 +++++++++++++ .../use_unwrapped_lib/use_builder_sig_api.mli | 1 + .../use_unwrapped_lib/use_unwrapped_lib.ml | 3 +++ .../use_wrapped_lib/use_builder_sig_api.ml | 17 ++++++++++++++ .../use_wrapped_lib/use_builder_sig_api.mli | 1 + .../bin/use_wrapped_lib/use_wrapped_lib.ml | 3 +++ .../lib/values/builder_sig_api/README.md | 12 ++++++++++ .../lib/values/builder_sig_api/bsa.ml | 12 ++++++++++ .../lib/values/builder_sig_api/bsa.mli | 3 +++ .../lib/values/builder_sig_api/bsa_api.ml | 12 ++++++++++ .../lib/values/builder_sig_api/bsa_builder.ml | 7 ++++++ .../values/builder_sig_api/bsa_builder.mli | 1 + .../values/builder_sig_api/bsa_use_less.ml | 8 +++++++ .../values/builder_sig_api/bsa_use_less.mli | 1 + 20 files changed, 139 insertions(+), 14 deletions(-) create mode 100644 examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.ml create mode 100644 examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.mli create mode 100644 examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.ml create mode 100644 examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.mli create mode 100644 examples/using_dune/lib/values/builder_sig_api/README.md create mode 100644 examples/using_dune/lib/values/builder_sig_api/bsa.ml create mode 100644 examples/using_dune/lib/values/builder_sig_api/bsa.mli create mode 100644 examples/using_dune/lib/values/builder_sig_api/bsa_api.ml create mode 100644 examples/using_dune/lib/values/builder_sig_api/bsa_builder.ml create mode 100644 examples/using_dune/lib/values/builder_sig_api/bsa_builder.mli create mode 100644 examples/using_dune/lib/values/builder_sig_api/bsa_use_less.ml create mode 100644 examples/using_dune/lib/values/builder_sig_api/bsa_use_less.mli diff --git a/check/classic/classic.ref b/check/classic/classic.ref index e6452e5..5cdb3ea 100644 --- a/check/classic/classic.ref +++ b/check/classic/classic.ref @@ -9,6 +9,7 @@ ./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:10: internally_used_fun_with_single_always_used_opt_arg ./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:12: internally_used_fun_with_single_sometimes_used_opt_arg +./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/unwrapped_lib/values/values.mli:3: internally_used_int ./examples/using_dune/unwrapped_lib/values/values.mli:14: unused_fun @@ -29,6 +30,8 @@ ./examples/using_dune/wrapped_lib/opt_args/opt_args.mli:10: internally_used_fun_with_single_always_used_opt_arg ./examples/using_dune/wrapped_lib/opt_args/opt_args.mli:12: internally_used_fun_with_single_sometimes_used_opt_arg +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/wrapped_lib/values/values.mli:3: internally_used_int ./examples/using_dune/wrapped_lib/values/values.mli:14: unused_fun @@ -533,7 +536,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 460 +Total: 463 Success: 460 -Failed: 0 -Ratio: 100.% +Failed: 3 +Ratio: 99.3520518359% diff --git a/check/internal/internal.ref b/check/internal/internal.ref index ef171b0..586a812 100644 --- a/check/internal/internal.ref +++ b/check/internal/internal.ref @@ -5,6 +5,7 @@ ./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg +./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/unwrapped_lib/values/values.mli:14: unused_fun ./examples/using_dune/unwrapped_lib/values/values.mli:20: unused_alias_fun @@ -18,6 +19,8 @@ ./examples/using_dune/wrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/wrapped_lib/values/values.mli:14: unused_fun ./examples/using_dune/wrapped_lib/values/values.mli:20: unused_alias_fun @@ -501,7 +504,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 430 +Total: 433 Success: 430 -Failed: 0 -Ratio: 100.% +Failed: 3 +Ratio: 99.3071593533% diff --git a/check/threshold-1/threshold-1.exp b/check/threshold-1/threshold-1.exp index 41ed3e7..4e41675 100644 --- a/check/threshold-1/threshold-1.exp +++ b/check/threshold-1/threshold-1.exp @@ -75,6 +75,7 @@ ./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_lib.mli:1: mark_used ./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_no_intf.mli:1: mark_used +./examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_constructors.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_opt_args.mli:1: mark_used @@ -89,6 +90,7 @@ ./examples/using_dune/bin/use_unwrapped_lib/use_with_class.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_without_class.mli:1: mark_used +./examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_constructors.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_opt_args.mli:1: mark_used diff --git a/check/threshold-1/threshold-1.ref b/check/threshold-1/threshold-1.ref index 1ef3c2f..cc0dac2 100644 --- a/check/threshold-1/threshold-1.ref +++ b/check/threshold-1/threshold-1.ref @@ -5,6 +5,7 @@ ./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg +./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/unwrapped_lib/values/values.mli:14: unused_fun ./examples/using_dune/unwrapped_lib/values/values.mli:20: unused_alias_fun @@ -18,6 +19,8 @@ ./examples/using_dune/wrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/wrapped_lib/values/values.mli:14: unused_fun ./examples/using_dune/wrapped_lib/values/values.mli:20: unused_alias_fun @@ -75,6 +78,7 @@ ./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_lib.mli:1: mark_used ./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_no_intf.mli:1: mark_used +./examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_constructors.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_opt_args.mli:1: mark_used @@ -89,6 +93,7 @@ ./examples/using_dune/bin/use_unwrapped_lib/use_with_class.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_without_class.mli:1: mark_used +./examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_constructors.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_opt_args.mli:1: mark_used @@ -809,7 +814,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 701 -Success: 701 -Failed: 0 -Ratio: 100.% +Total: 706 +Success: 703 +Failed: 3 +Ratio: 99.5750708215% diff --git a/check/threshold-3-0.5/threshold-3-0.5.exp b/check/threshold-3-0.5/threshold-3-0.5.exp index 49014d8..93a5ee9 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.exp +++ b/check/threshold-3-0.5/threshold-3-0.5.exp @@ -75,6 +75,7 @@ ./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_lib.mli:1: mark_used ./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_no_intf.mli:1: mark_used +./examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_constructors.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_opt_args.mli:1: mark_used @@ -89,6 +90,7 @@ ./examples/using_dune/bin/use_unwrapped_lib/use_with_class.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_without_class.mli:1: mark_used +./examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_constructors.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_opt_args.mli:1: mark_used diff --git a/check/threshold-3-0.5/threshold-3-0.5.ref b/check/threshold-3-0.5/threshold-3-0.5.ref index 60e2afc..b37ef7b 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.ref +++ b/check/threshold-3-0.5/threshold-3-0.5.ref @@ -5,6 +5,7 @@ ./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg +./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/unwrapped_lib/values/values.mli:14: unused_fun ./examples/using_dune/unwrapped_lib/values/values.mli:20: unused_alias_fun @@ -18,6 +19,8 @@ ./examples/using_dune/wrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/wrapped_lib/values/values.mli:14: unused_fun ./examples/using_dune/wrapped_lib/values/values.mli:20: unused_alias_fun @@ -75,6 +78,7 @@ ./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_lib.mli:1: mark_used ./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_no_intf.mli:1: mark_used +./examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_constructors.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_opt_args.mli:1: mark_used @@ -89,6 +93,7 @@ ./examples/using_dune/bin/use_unwrapped_lib/use_with_class.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_without_class.mli:1: mark_used +./examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_constructors.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_opt_args.mli:1: mark_used @@ -262,6 +267,9 @@ ./examples/using_dune/unwrapped_lib/opt_args/opt_args_in_higher_order_fun.mli:13: expect_fun_with_never_used_opt_arg_with_sig ./examples/using_dune/unwrapped_lib/opt_args/opt_args_in_higher_order_fun.mli:15: expect_fun_with_always_used_opt_arg_with_sig +./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:9: internally_used: Should not be detected +./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:10: externally_used: Should not be detected +./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:11: sometimes_used: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:1: used_int ./examples/using_dune/unwrapped_lib/values/values.mli:13: used_fun ./examples/using_dune/unwrapped_lib/values/values.mli:19: used_alias_fun @@ -291,6 +299,12 @@ ./examples/using_dune/wrapped_lib/opt_args/opt_args_in_higher_order_fun.mli:13: expect_fun_with_never_used_opt_arg_with_sig ./examples/using_dune/wrapped_lib/opt_args/opt_args_in_higher_order_fun.mli:15: expect_fun_with_always_used_opt_arg_with_sig +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:9: internally_used: Should not be detected +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:9: internally_used: Should not be detected +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:10: externally_used: Should not be detected +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:10: externally_used: Should not be detected +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:11: sometimes_used: Should not be detected +./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:11: sometimes_used: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:1: used_int ./examples/using_dune/wrapped_lib/values/values.mli:13: used_fun ./examples/using_dune/wrapped_lib/values/values.mli:19: used_alias_fun @@ -1168,7 +1182,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 988 -Success: 988 -Failed: 0 -Ratio: 100.% +Total: 1002 +Success: 990 +Failed: 12 +Ratio: 98.8023952096% diff --git a/examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.ml b/examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.ml new file mode 100644 index 0000000..e595887 --- /dev/null +++ b/examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.ml @@ -0,0 +1,15 @@ +(* use Bsa *) +let () = + ignore Bsa.Parameter.used; + ignore Bsa.used; + ignore Bsa.externally_used; + ignore Bsa.sometimes_used + +(* use Bsa_less *) +let () = + ignore Bsa_use_less.used; + ignore Bsa_use_less.externally_used + +let is_used = ref false +let mark_used () = + is_used := true diff --git a/examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.mli b/examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.mli new file mode 100644 index 0000000..f84c4cb --- /dev/null +++ b/examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.mli @@ -0,0 +1 @@ +val mark_used : unit -> unit diff --git a/examples/using_dune/bin/use_unwrapped_lib/use_unwrapped_lib.ml b/examples/using_dune/bin/use_unwrapped_lib/use_unwrapped_lib.ml index 78da673..aaba0db 100644 --- a/examples/using_dune/bin/use_unwrapped_lib/use_unwrapped_lib.ml +++ b/examples/using_dune/bin/use_unwrapped_lib/use_unwrapped_lib.ml @@ -20,6 +20,9 @@ let () = let () = Use_style.mark_used () +let () = + Use_builder_sig_api.mark_used () + let is_used = ref false let mark_used () = is_used := true diff --git a/examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.ml b/examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.ml new file mode 100644 index 0000000..5a9788d --- /dev/null +++ b/examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.ml @@ -0,0 +1,17 @@ +open Wrapped_lib + +(* use Bsa *) +let () = + ignore Bsa.Parameter.used; + ignore Bsa.used; + ignore Bsa.externally_used; + ignore Bsa.sometimes_used + +(* use Bsa_less *) +let () = + ignore Bsa_use_less.used; + ignore Bsa_use_less.externally_used + +let is_used = ref false +let mark_used () = + is_used := true diff --git a/examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.mli b/examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.mli new file mode 100644 index 0000000..f84c4cb --- /dev/null +++ b/examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.mli @@ -0,0 +1 @@ +val mark_used : unit -> unit diff --git a/examples/using_dune/bin/use_wrapped_lib/use_wrapped_lib.ml b/examples/using_dune/bin/use_wrapped_lib/use_wrapped_lib.ml index 78da673..aaba0db 100644 --- a/examples/using_dune/bin/use_wrapped_lib/use_wrapped_lib.ml +++ b/examples/using_dune/bin/use_wrapped_lib/use_wrapped_lib.ml @@ -20,6 +20,9 @@ let () = let () = Use_style.mark_used () +let () = + Use_builder_sig_api.mark_used () + let is_used = ref false let mark_used () = is_used := true diff --git a/examples/using_dune/lib/values/builder_sig_api/README.md b/examples/using_dune/lib/values/builder_sig_api/README.md new file mode 100644 index 0000000..3e73a3a --- /dev/null +++ b/examples/using_dune/lib/values/builder_sig_api/README.md @@ -0,0 +1,12 @@ +This is a pattern observed on Frama-C. + +A `module_api.ml` defines the module types, `module.ml` implements modules of +those module type and `module.mli` creates the link by exposing modules in the +implmentation with types from the api. +Additionally, there may be a `module_builder.ml` (and `.mli`) which defines +functors (in particular `Make`) using module types from the api. + +An example of this pattern can be found in the Frama-C project in +`src/kernel_services/ast_printing/` with `module = printer`. +A variation of this example, with a `module_sig.ml` for the api can be found in +`src/kernel_services/cmdline_parameters/`. This time `module = parameter` diff --git a/examples/using_dune/lib/values/builder_sig_api/bsa.ml b/examples/using_dune/lib/values/builder_sig_api/bsa.ml new file mode 100644 index 0000000..0b66306 --- /dev/null +++ b/examples/using_dune/lib/values/builder_sig_api/bsa.ml @@ -0,0 +1,12 @@ +module Parameter = struct + let used_by_functor_app = 42 + let used = 42 +end + +include Bsa_builder.Make(Parameter) + +let () = + ignore Parameter.used; + ignore used; + ignore internally_used; + ignore sometimes_used diff --git a/examples/using_dune/lib/values/builder_sig_api/bsa.mli b/examples/using_dune/lib/values/builder_sig_api/bsa.mli new file mode 100644 index 0000000..fba2d5e --- /dev/null +++ b/examples/using_dune/lib/values/builder_sig_api/bsa.mli @@ -0,0 +1,3 @@ +module Parameter : Bsa_api.PARAM + +include Bsa_api.S diff --git a/examples/using_dune/lib/values/builder_sig_api/bsa_api.ml b/examples/using_dune/lib/values/builder_sig_api/bsa_api.ml new file mode 100644 index 0000000..93db6a3 --- /dev/null +++ b/examples/using_dune/lib/values/builder_sig_api/bsa_api.ml @@ -0,0 +1,12 @@ +module type PARAM = sig + val used_by_functor_app : int + val used : int +end + +module type S = sig + val unused : int + val used : int + val internally_used :int + val externally_used :int + val sometimes_used : int +end diff --git a/examples/using_dune/lib/values/builder_sig_api/bsa_builder.ml b/examples/using_dune/lib/values/builder_sig_api/bsa_builder.ml new file mode 100644 index 0000000..090f2ca --- /dev/null +++ b/examples/using_dune/lib/values/builder_sig_api/bsa_builder.ml @@ -0,0 +1,7 @@ +module Make (P: Bsa_api.PARAM) = struct + let unused = P.used + let used = P.used + let internally_used = P.used + let externally_used = P.used + let sometimes_used = P.used +end diff --git a/examples/using_dune/lib/values/builder_sig_api/bsa_builder.mli b/examples/using_dune/lib/values/builder_sig_api/bsa_builder.mli new file mode 100644 index 0000000..1989c82 --- /dev/null +++ b/examples/using_dune/lib/values/builder_sig_api/bsa_builder.mli @@ -0,0 +1 @@ +module Make (_: Bsa_api.PARAM) : Bsa_api.S diff --git a/examples/using_dune/lib/values/builder_sig_api/bsa_use_less.ml b/examples/using_dune/lib/values/builder_sig_api/bsa_use_less.ml new file mode 100644 index 0000000..1400c25 --- /dev/null +++ b/examples/using_dune/lib/values/builder_sig_api/bsa_use_less.ml @@ -0,0 +1,8 @@ +include Bsa_builder.Make(struct + let used_by_functor_app = 42 + let used = 42 + end) + +let () = + ignore used; + ignore internally_used diff --git a/examples/using_dune/lib/values/builder_sig_api/bsa_use_less.mli b/examples/using_dune/lib/values/builder_sig_api/bsa_use_less.mli new file mode 100644 index 0000000..57a3eae --- /dev/null +++ b/examples/using_dune/lib/values/builder_sig_api/bsa_use_less.mli @@ -0,0 +1 @@ +include Bsa_api.S From 6ce1d9486f0a36711756a7e9f060afe0c8df0c15 Mon Sep 17 00:00:00 2001 From: Corentin De Souza <9597216+fantazio@users.noreply.github.com> Date: Mon, 26 Jan 2026 12:15:17 +0100 Subject: [PATCH 2/3] [examples][dune] add tests for module type inclusion It is not uncommon to use a `.ml` (without `.mli`) to expose module types and include these in other module's `.mli`. The new tests specifically target this pattern with a toplevel `include` The current report semantic for the values in module types is to not report them. --- check/classic/classic.ref | 10 ++++--- check/internal/internal.ref | 10 ++++--- check/threshold-1/threshold-1.exp | 2 ++ check/threshold-1/threshold-1.ref | 14 +++++++--- check/threshold-3-0.5/threshold-3-0.5.exp | 2 ++ check/threshold-3-0.5/threshold-3-0.5.ref | 26 ++++++++++++++++--- .../use_unwrapped_lib/use_include_modtype.ml | 14 ++++++++++ .../use_unwrapped_lib/use_include_modtype.mli | 1 + .../use_unwrapped_lib/use_unwrapped_lib.ml | 3 +++ .../use_wrapped_lib/use_include_modtype.ml | 16 ++++++++++++ .../use_wrapped_lib/use_include_modtype.mli | 1 + .../bin/use_wrapped_lib/use_wrapped_lib.ml | 3 +++ .../lib/values/include_modtype/imt_include.ml | 10 +++++++ .../values/include_modtype/imt_include.mli | 1 + .../include_modtype/imt_include_use_less.ml | 9 +++++++ .../include_modtype/imt_include_use_less.mli | 1 + .../lib/values/include_modtype/imt_modtype.ml | 7 +++++ 17 files changed, 116 insertions(+), 14 deletions(-) create mode 100644 examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.ml create mode 100644 examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.mli create mode 100644 examples/using_dune/bin/use_wrapped_lib/use_include_modtype.ml create mode 100644 examples/using_dune/bin/use_wrapped_lib/use_include_modtype.mli create mode 100644 examples/using_dune/lib/values/include_modtype/imt_include.ml create mode 100644 examples/using_dune/lib/values/include_modtype/imt_include.mli create mode 100644 examples/using_dune/lib/values/include_modtype/imt_include_use_less.ml create mode 100644 examples/using_dune/lib/values/include_modtype/imt_include_use_less.mli create mode 100644 examples/using_dune/lib/values/include_modtype/imt_modtype.ml diff --git a/check/classic/classic.ref b/check/classic/classic.ref index 5cdb3ea..a96f49d 100644 --- a/check/classic/classic.ref +++ b/check/classic/classic.ref @@ -10,6 +10,8 @@ ./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:12: internally_used_fun_with_single_sometimes_used_opt_arg ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/unwrapped_lib/values/values.mli:3: internally_used_int ./examples/using_dune/unwrapped_lib/values/values.mli:14: unused_fun @@ -32,6 +34,8 @@ ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/wrapped_lib/values/values.mli:3: internally_used_int ./examples/using_dune/wrapped_lib/values/values.mli:14: unused_fun @@ -536,7 +540,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 463 +Total: 467 Success: 460 -Failed: 3 -Ratio: 99.3520518359% +Failed: 7 +Ratio: 98.5010706638% diff --git a/check/internal/internal.ref b/check/internal/internal.ref index 586a812..69c4d64 100644 --- a/check/internal/internal.ref +++ b/check/internal/internal.ref @@ -6,6 +6,8 @@ ./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/unwrapped_lib/values/values.mli:14: unused_fun ./examples/using_dune/unwrapped_lib/values/values.mli:20: unused_alias_fun @@ -21,6 +23,8 @@ ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/wrapped_lib/values/values.mli:14: unused_fun ./examples/using_dune/wrapped_lib/values/values.mli:20: unused_alias_fun @@ -504,7 +508,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 433 +Total: 437 Success: 430 -Failed: 3 -Ratio: 99.3071593533% +Failed: 7 +Ratio: 98.3981693364% diff --git a/check/threshold-1/threshold-1.exp b/check/threshold-1/threshold-1.exp index 4e41675..8be6a91 100644 --- a/check/threshold-1/threshold-1.exp +++ b/check/threshold-1/threshold-1.exp @@ -77,6 +77,7 @@ ./examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_constructors.mli:1: mark_used +./examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_opt_args.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_opt_args_in_higher_order_fun.mli:1: mark_used @@ -92,6 +93,7 @@ ./examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_constructors.mli:1: mark_used +./examples/using_dune/bin/use_wrapped_lib/use_include_modtype.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_opt_args.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_opt_args_in_higher_order_fun.mli:1: mark_used diff --git a/check/threshold-1/threshold-1.ref b/check/threshold-1/threshold-1.ref index cc0dac2..dc11782 100644 --- a/check/threshold-1/threshold-1.ref +++ b/check/threshold-1/threshold-1.ref @@ -6,6 +6,8 @@ ./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/unwrapped_lib/values/values.mli:14: unused_fun ./examples/using_dune/unwrapped_lib/values/values.mli:20: unused_alias_fun @@ -21,6 +23,8 @@ ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/wrapped_lib/values/values.mli:14: unused_fun ./examples/using_dune/wrapped_lib/values/values.mli:20: unused_alias_fun @@ -80,6 +84,7 @@ ./examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_constructors.mli:1: mark_used +./examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_opt_args.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_opt_args_in_higher_order_fun.mli:1: mark_used @@ -95,6 +100,7 @@ ./examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_constructors.mli:1: mark_used +./examples/using_dune/bin/use_wrapped_lib/use_include_modtype.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_opt_args.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_opt_args_in_higher_order_fun.mli:1: mark_used @@ -814,7 +820,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 706 -Success: 703 -Failed: 3 -Ratio: 99.5750708215% +Total: 712 +Success: 705 +Failed: 7 +Ratio: 99.0168539326% diff --git a/check/threshold-3-0.5/threshold-3-0.5.exp b/check/threshold-3-0.5/threshold-3-0.5.exp index 93a5ee9..ea49a4f 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.exp +++ b/check/threshold-3-0.5/threshold-3-0.5.exp @@ -77,6 +77,7 @@ ./examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_constructors.mli:1: mark_used +./examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_opt_args.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_opt_args_in_higher_order_fun.mli:1: mark_used @@ -92,6 +93,7 @@ ./examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_constructors.mli:1: mark_used +./examples/using_dune/bin/use_wrapped_lib/use_include_modtype.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_opt_args.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_opt_args_in_higher_order_fun.mli:1: mark_used diff --git a/check/threshold-3-0.5/threshold-3-0.5.ref b/check/threshold-3-0.5/threshold-3-0.5.ref index b37ef7b..03e11a8 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.ref +++ b/check/threshold-3-0.5/threshold-3-0.5.ref @@ -6,6 +6,8 @@ ./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/unwrapped_lib/values/values.mli:14: unused_fun ./examples/using_dune/unwrapped_lib/values/values.mli:20: unused_alias_fun @@ -21,6 +23,8 @@ ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:2: unused_int ./examples/using_dune/wrapped_lib/values/values.mli:14: unused_fun ./examples/using_dune/wrapped_lib/values/values.mli:20: unused_alias_fun @@ -80,6 +84,7 @@ ./examples/using_dune/bin/use_unwrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_constructors.mli:1: mark_used +./examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_opt_args.mli:1: mark_used ./examples/using_dune/bin/use_unwrapped_lib/use_opt_args_in_higher_order_fun.mli:1: mark_used @@ -95,6 +100,7 @@ ./examples/using_dune/bin/use_wrapped_lib/use_builder_sig_api.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_constructors.mli:1: mark_used +./examples/using_dune/bin/use_wrapped_lib/use_include_modtype.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_mixed_args.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_opt_args.mli:1: mark_used ./examples/using_dune/bin/use_wrapped_lib/use_opt_args_in_higher_order_fun.mli:1: mark_used @@ -270,6 +276,12 @@ ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:9: internally_used: Should not be detected ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:10: externally_used: Should not be detected ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:11: sometimes_used: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:4: internally_used: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:4: internally_used: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:5: externally_used: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:5: externally_used: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:6: sometimes_used: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:6: sometimes_used: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:1: used_int ./examples/using_dune/unwrapped_lib/values/values.mli:13: used_fun ./examples/using_dune/unwrapped_lib/values/values.mli:19: used_alias_fun @@ -305,6 +317,12 @@ ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:10: externally_used: Should not be detected ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:11: sometimes_used: Should not be detected ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:11: sometimes_used: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:4: internally_used: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:4: internally_used: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:5: externally_used: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:5: externally_used: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:6: sometimes_used: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:6: sometimes_used: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:1: used_int ./examples/using_dune/wrapped_lib/values/values.mli:13: used_fun ./examples/using_dune/wrapped_lib/values/values.mli:19: used_alias_fun @@ -1182,7 +1200,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 1002 -Success: 990 -Failed: 12 -Ratio: 98.8023952096% +Total: 1020 +Success: 992 +Failed: 28 +Ratio: 97.2549019608% diff --git a/examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.ml b/examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.ml new file mode 100644 index 0000000..39e6b34 --- /dev/null +++ b/examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.ml @@ -0,0 +1,14 @@ +(* use Imt_include *) +let () = + ignore Imt_include.used; + ignore Imt_include.externally_used; + ignore Imt_include.sometimes_used + +(* use Imt_include_use_less *) +let () = + ignore Imt_include_use_less.used; + ignore Imt_include_use_less.externally_used + +let is_used = ref false +let mark_used () = + is_used := true diff --git a/examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.mli b/examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.mli new file mode 100644 index 0000000..f84c4cb --- /dev/null +++ b/examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.mli @@ -0,0 +1 @@ +val mark_used : unit -> unit diff --git a/examples/using_dune/bin/use_unwrapped_lib/use_unwrapped_lib.ml b/examples/using_dune/bin/use_unwrapped_lib/use_unwrapped_lib.ml index aaba0db..71eaf36 100644 --- a/examples/using_dune/bin/use_unwrapped_lib/use_unwrapped_lib.ml +++ b/examples/using_dune/bin/use_unwrapped_lib/use_unwrapped_lib.ml @@ -23,6 +23,9 @@ let () = let () = Use_builder_sig_api.mark_used () +let () = + Use_include_modtype.mark_used () + let is_used = ref false let mark_used () = is_used := true diff --git a/examples/using_dune/bin/use_wrapped_lib/use_include_modtype.ml b/examples/using_dune/bin/use_wrapped_lib/use_include_modtype.ml new file mode 100644 index 0000000..7386feb --- /dev/null +++ b/examples/using_dune/bin/use_wrapped_lib/use_include_modtype.ml @@ -0,0 +1,16 @@ +open Wrapped_lib + +(* use Imt_include *) +let () = + ignore Imt_include.used; + ignore Imt_include.externally_used; + ignore Imt_include.sometimes_used + +(* use Imt_include_use_less *) +let () = + ignore Imt_include_use_less.used; + ignore Imt_include_use_less.externally_used + +let is_used = ref false +let mark_used () = + is_used := true diff --git a/examples/using_dune/bin/use_wrapped_lib/use_include_modtype.mli b/examples/using_dune/bin/use_wrapped_lib/use_include_modtype.mli new file mode 100644 index 0000000..f84c4cb --- /dev/null +++ b/examples/using_dune/bin/use_wrapped_lib/use_include_modtype.mli @@ -0,0 +1 @@ +val mark_used : unit -> unit diff --git a/examples/using_dune/bin/use_wrapped_lib/use_wrapped_lib.ml b/examples/using_dune/bin/use_wrapped_lib/use_wrapped_lib.ml index aaba0db..71eaf36 100644 --- a/examples/using_dune/bin/use_wrapped_lib/use_wrapped_lib.ml +++ b/examples/using_dune/bin/use_wrapped_lib/use_wrapped_lib.ml @@ -23,6 +23,9 @@ let () = let () = Use_builder_sig_api.mark_used () +let () = + Use_include_modtype.mark_used () + let is_used = ref false let mark_used () = is_used := true diff --git a/examples/using_dune/lib/values/include_modtype/imt_include.ml b/examples/using_dune/lib/values/include_modtype/imt_include.ml new file mode 100644 index 0000000..59175bd --- /dev/null +++ b/examples/using_dune/lib/values/include_modtype/imt_include.ml @@ -0,0 +1,10 @@ +let unused = 42 +let used = 42 +let internally_used = 42 +let externally_used = 42 +let sometimes_used = 42 + +let () = + ignore used; + ignore internally_used; + ignore sometimes_used diff --git a/examples/using_dune/lib/values/include_modtype/imt_include.mli b/examples/using_dune/lib/values/include_modtype/imt_include.mli new file mode 100644 index 0000000..be68770 --- /dev/null +++ b/examples/using_dune/lib/values/include_modtype/imt_include.mli @@ -0,0 +1 @@ +include Imt_modtype.S diff --git a/examples/using_dune/lib/values/include_modtype/imt_include_use_less.ml b/examples/using_dune/lib/values/include_modtype/imt_include_use_less.ml new file mode 100644 index 0000000..9c15342 --- /dev/null +++ b/examples/using_dune/lib/values/include_modtype/imt_include_use_less.ml @@ -0,0 +1,9 @@ +let unused = 42 +let used = 42 +let internally_used = 42 +let externally_used = 42 +let sometimes_used = 42 + +let () = + ignore used; + ignore internally_used diff --git a/examples/using_dune/lib/values/include_modtype/imt_include_use_less.mli b/examples/using_dune/lib/values/include_modtype/imt_include_use_less.mli new file mode 100644 index 0000000..be68770 --- /dev/null +++ b/examples/using_dune/lib/values/include_modtype/imt_include_use_less.mli @@ -0,0 +1 @@ +include Imt_modtype.S diff --git a/examples/using_dune/lib/values/include_modtype/imt_modtype.ml b/examples/using_dune/lib/values/include_modtype/imt_modtype.ml new file mode 100644 index 0000000..13ea67e --- /dev/null +++ b/examples/using_dune/lib/values/include_modtype/imt_modtype.ml @@ -0,0 +1,7 @@ +module type S = sig + val unused : int + val used : int + val internally_used :int + val externally_used :int + val sometimes_used : int +end From 71ecf02aeef8b95ee9eb6322515eda29f061ac08 Mon Sep 17 00:00:00 2001 From: Corentin De Souza <9597216+fantazio@users.noreply.github.com> Date: Wed, 28 Jan 2026 14:48:06 +0100 Subject: [PATCH 3/3] [examples][dune] add tests for internal module type inclusion Instead of including a modtype from an external module in the signature, the same module both defines and includes a modtype in its signature. The current report semantic for the values in module types is to not report them. --- check/classic/classic.ref | 10 +++++++--- check/internal/internal.ref | 8 +++++--- check/threshold-1/threshold-1.ref | 12 +++++++++--- check/threshold-3-0.5/threshold-3-0.5.ref | 14 +++++++++++--- .../use_unwrapped_lib/use_include_modtype.ml | 5 +++++ .../bin/use_wrapped_lib/use_include_modtype.ml | 5 +++++ .../include_modtype/imt_internal_include.ml | 17 +++++++++++++++++ .../include_modtype/imt_internal_include.mli | 8 ++++++++ 8 files changed, 67 insertions(+), 12 deletions(-) create mode 100644 examples/using_dune/lib/values/include_modtype/imt_internal_include.ml create mode 100644 examples/using_dune/lib/values/include_modtype/imt_internal_include.mli diff --git a/check/classic/classic.ref b/check/classic/classic.ref index a96f49d..b673379 100644 --- a/check/classic/classic.ref +++ b/check/classic/classic.ref @@ -10,6 +10,8 @@ ./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:12: internally_used_fun_with_single_sometimes_used_opt_arg ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_internal_include.mli:2: unused: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_internal_include.mli:4: internally_used: Should not be detected ./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:2: unused_int @@ -34,6 +36,8 @@ ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_internal_include.mli:2: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_internal_include.mli:4: internally_used: Should not be detected ./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:2: unused_int @@ -540,7 +544,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 467 +Total: 471 Success: 460 -Failed: 7 -Ratio: 98.5010706638% +Failed: 11 +Ratio: 97.6645435244% diff --git a/check/internal/internal.ref b/check/internal/internal.ref index 69c4d64..9f4af00 100644 --- a/check/internal/internal.ref +++ b/check/internal/internal.ref @@ -6,6 +6,7 @@ ./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_internal_include.mli:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:2: unused_int @@ -23,6 +24,7 @@ ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_internal_include.mli:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:2: unused_int @@ -508,7 +510,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 437 +Total: 439 Success: 430 -Failed: 7 -Ratio: 98.3981693364% +Failed: 9 +Ratio: 97.9498861048% diff --git a/check/threshold-1/threshold-1.ref b/check/threshold-1/threshold-1.ref index dc11782..53531d9 100644 --- a/check/threshold-1/threshold-1.ref +++ b/check/threshold-1/threshold-1.ref @@ -6,6 +6,7 @@ ./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_internal_include.mli:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:2: unused_int @@ -23,6 +24,7 @@ ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_internal_include.mli:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:2: unused_int @@ -126,6 +128,8 @@ ./examples/using_dune/unwrapped_lib/style/style.ml:1: all +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_internal_include.mli:4: internally_used: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_internal_include.mli:5: externally_used: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:3: internally_used_int ./examples/using_dune/unwrapped_lib/values/values.mli:4: externally_used_int ./examples/using_dune/unwrapped_lib/values/values.mli:5: externally_used_as_parameter_int @@ -164,6 +168,8 @@ ./examples/using_dune/wrapped_lib/style/style.ml:1: all +./examples/using_dune/wrapped_lib/values/include_modtype/imt_internal_include.mli:4: internally_used: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_internal_include.mli:5: externally_used: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:3: internally_used_int ./examples/using_dune/wrapped_lib/values/values.mli:4: externally_used_int ./examples/using_dune/wrapped_lib/values/values.mli:5: externally_used_as_parameter_int @@ -820,7 +826,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 712 +Total: 718 Success: 705 -Failed: 7 -Ratio: 99.0168539326% +Failed: 13 +Ratio: 98.1894150418% diff --git a/check/threshold-3-0.5/threshold-3-0.5.ref b/check/threshold-3-0.5/threshold-3-0.5.ref index 03e11a8..616e1e0 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.ref +++ b/check/threshold-3-0.5/threshold-3-0.5.ref @@ -6,6 +6,7 @@ ./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_internal_include.mli:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:2: unused_int @@ -23,6 +24,7 @@ ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:7: unused: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_internal_include.mli:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:2: unused: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:2: unused_int @@ -126,6 +128,8 @@ ./examples/using_dune/unwrapped_lib/style/style.ml:1: all +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_internal_include.mli:4: internally_used: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_internal_include.mli:5: externally_used: Should not be detected ./examples/using_dune/unwrapped_lib/values/values.mli:3: internally_used_int ./examples/using_dune/unwrapped_lib/values/values.mli:4: externally_used_int ./examples/using_dune/unwrapped_lib/values/values.mli:5: externally_used_as_parameter_int @@ -164,6 +168,8 @@ ./examples/using_dune/wrapped_lib/style/style.ml:1: all +./examples/using_dune/wrapped_lib/values/include_modtype/imt_internal_include.mli:4: internally_used: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_internal_include.mli:5: externally_used: Should not be detected ./examples/using_dune/wrapped_lib/values/values.mli:3: internally_used_int ./examples/using_dune/wrapped_lib/values/values.mli:4: externally_used_int ./examples/using_dune/wrapped_lib/values/values.mli:5: externally_used_as_parameter_int @@ -276,6 +282,7 @@ ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:9: internally_used: Should not be detected ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:10: externally_used: Should not be detected ./examples/using_dune/unwrapped_lib/values/builder_sig_api/bsa_api.ml:11: sometimes_used: Should not be detected +./examples/using_dune/unwrapped_lib/values/include_modtype/imt_internal_include.mli:3: used: Should not be detected ./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:4: internally_used: Should not be detected ./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:4: internally_used: Should not be detected ./examples/using_dune/unwrapped_lib/values/include_modtype/imt_modtype.ml:5: externally_used: Should not be detected @@ -317,6 +324,7 @@ ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:10: externally_used: Should not be detected ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:11: sometimes_used: Should not be detected ./examples/using_dune/wrapped_lib/values/builder_sig_api/bsa_api.ml:11: sometimes_used: Should not be detected +./examples/using_dune/wrapped_lib/values/include_modtype/imt_internal_include.mli:3: used: Should not be detected ./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:4: internally_used: Should not be detected ./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:4: internally_used: Should not be detected ./examples/using_dune/wrapped_lib/values/include_modtype/imt_modtype.ml:5: externally_used: Should not be detected @@ -1200,7 +1208,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 1020 +Total: 1028 Success: 992 -Failed: 28 -Ratio: 97.2549019608% +Failed: 36 +Ratio: 96.4980544747% diff --git a/examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.ml b/examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.ml index 39e6b34..e9d0636 100644 --- a/examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.ml +++ b/examples/using_dune/bin/use_unwrapped_lib/use_include_modtype.ml @@ -9,6 +9,11 @@ let () = ignore Imt_include_use_less.used; ignore Imt_include_use_less.externally_used +(* use Imt_internal_include *) +let () = + ignore Imt_internal_include.used; + ignore Imt_internal_include.externally_used + let is_used = ref false let mark_used () = is_used := true diff --git a/examples/using_dune/bin/use_wrapped_lib/use_include_modtype.ml b/examples/using_dune/bin/use_wrapped_lib/use_include_modtype.ml index 7386feb..619f563 100644 --- a/examples/using_dune/bin/use_wrapped_lib/use_include_modtype.ml +++ b/examples/using_dune/bin/use_wrapped_lib/use_include_modtype.ml @@ -11,6 +11,11 @@ let () = ignore Imt_include_use_less.used; ignore Imt_include_use_less.externally_used +(* use Imt_internal_include *) +let () = + ignore Imt_internal_include.used; + ignore Imt_internal_include.externally_used + let is_used = ref false let mark_used () = is_used := true diff --git a/examples/using_dune/lib/values/include_modtype/imt_internal_include.ml b/examples/using_dune/lib/values/include_modtype/imt_internal_include.ml new file mode 100644 index 0000000..c4e88e5 --- /dev/null +++ b/examples/using_dune/lib/values/include_modtype/imt_internal_include.ml @@ -0,0 +1,17 @@ +module type S = sig + val unused : int + val used : int + val internally_used :int + val externally_used :int +end + +let unused = 42 +let used = 42 +let internally_used = 42 +let externally_used = 42 +let sometimes_used = 42 + +let () = + ignore used; + ignore internally_used; + ignore sometimes_used diff --git a/examples/using_dune/lib/values/include_modtype/imt_internal_include.mli b/examples/using_dune/lib/values/include_modtype/imt_internal_include.mli new file mode 100644 index 0000000..1b7f2c1 --- /dev/null +++ b/examples/using_dune/lib/values/include_modtype/imt_internal_include.mli @@ -0,0 +1,8 @@ +module type S = sig + val unused : int + val used : int + val internally_used :int + val externally_used :int +end + +include S