From c6d0e06ab0d1cfcec47a1d1fa00678a4310afd1f Mon Sep 17 00:00:00 2001 From: Corentin De Souza <9597216+fantazio@users.noreply.github.com> Date: Mon, 3 Aug 2026 11:19:55 +0200 Subject: [PATCH 1/3] [check] unveil a false positive Content of module types should not be tracked according to the analyzer's semantics. An old example's expected results were not updated when the semantics were decided, hiding a false positive as a true positive. --- check/threshold-1/threshold-1.exp | 1 - check/threshold-1/threshold-1.ref | 8 ++++---- check/threshold-3-0.5/threshold-3-0.5.exp | 1 - check/threshold-3-0.5/threshold-3-0.5.ref | 8 ++++---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/check/threshold-1/threshold-1.exp b/check/threshold-1/threshold-1.exp index 65c58dc..64e180d 100644 --- a/check/threshold-1/threshold-1.exp +++ b/check/threshold-1/threshold-1.exp @@ -546,7 +546,6 @@ Nothing else to report in this section ./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#used_fun ./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#used_int -./examples/using_make/advanced/func.mli:3: M.c#f ./examples/using_make/advanced/mod.mli:4: p#f ./examples/using_make/obj/class.mli:1: c#f diff --git a/check/threshold-1/threshold-1.ref b/check/threshold-1/threshold-1.ref index eb6e126..ada8803 100644 --- a/check/threshold-1/threshold-1.ref +++ b/check/threshold-1/threshold-1.ref @@ -550,7 +550,7 @@ Nothing else to report in this section ./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#used_fun ./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#used_int -./examples/using_make/advanced/func.mli:3: M.c#f +./examples/using_make/advanced/func.mli:3: M.c#f: Should not be detected ./examples/using_make/advanced/mod.mli:4: p#f ./examples/using_make/obj/class.mli:1: c#f @@ -1128,6 +1128,6 @@ Nothing else to report in this section Total: 929 -Success: 921 -Failed: 8 -Ratio: 99.1388589882% +Success: 920 +Failed: 9 +Ratio: 99.0312163617% 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 93d15ad..45a54fa 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.exp +++ b/check/threshold-3-0.5/threshold-3-0.5.exp @@ -689,7 +689,6 @@ Nothing else to report in this section ./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#used_fun ./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#used_int -./examples/using_make/advanced/func.mli:3: M.c#f ./examples/using_make/advanced/mod.mli:4: p#f ./examples/using_make/obj/class.mli:1: c#f 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 e04bb50..3868976 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.ref +++ b/check/threshold-3-0.5/threshold-3-0.5.ref @@ -693,7 +693,7 @@ Nothing else to report in this section ./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#used_fun ./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#used_int -./examples/using_make/advanced/func.mli:3: M.c#f +./examples/using_make/advanced/func.mli:3: M.c#f: Should not be detected ./examples/using_make/advanced/mod.mli:4: p#f ./examples/using_make/obj/class.mli:1: c#f @@ -1532,6 +1532,6 @@ Nothing else to report in this section Total: 1251 -Success: 1243 -Failed: 8 -Ratio: 99.3605115907% +Success: 1242 +Failed: 9 +Ratio: 99.2805755396% From 0bf7380824d5093054ce2af2b7519e21fa6e5d59 Mon Sep 17 00:00:00 2001 From: Corentin De Souza <9597216+fantazio@users.noreply.github.com> Date: Mon, 3 Aug 2026 11:49:08 +0200 Subject: [PATCH 2/3] [examples][docs] move sigincl limitation The limitation was in the exported values. It is now a general limitation. A new `examples/docs/limitations` was created to expose general limitations. The documentation, expected, and ref results have been updated accordingly. The module type limitation is now documented as a general limitations as well. --- check/classic/classic.exp | 2 +- check/classic/classic.ref | 4 +- check/internal/internal.exp | 2 +- check/internal/internal.ref | 4 +- check/threshold-1/threshold-1.exp | 2 +- check/threshold-1/threshold-1.ref | 4 +- check/threshold-3-0.5/threshold-3-0.5.exp | 2 +- check/threshold-3-0.5/threshold-3-0.5.ref | 4 +- docs/LIMITATIONS.md | 111 ++++++++++++++++++ docs/USER_DOC.md | 1 + docs/exported_values/EXPORTED_VALUES.md | 103 ---------------- examples/docs/Makefile | 2 + .../docs/exported_values/limitations/Makefile | 2 - examples/docs/limitations/Makefile | 10 ++ .../limitations/sigincl/Makefile | 2 +- .../limitations/sigincl/sigincl_lib.ml | 0 .../limitations/sigincl/sigincl_lib.mli | 0 17 files changed, 137 insertions(+), 118 deletions(-) create mode 100644 docs/LIMITATIONS.md create mode 100644 examples/docs/limitations/Makefile rename examples/docs/{exported_values => }/limitations/sigincl/Makefile (77%) rename examples/docs/{exported_values => }/limitations/sigincl/sigincl_lib.ml (100%) rename examples/docs/{exported_values => }/limitations/sigincl/sigincl_lib.mli (100%) diff --git a/check/classic/classic.exp b/check/classic/classic.exp index fa87157..84fd0e4 100644 --- a/check/classic/classic.exp +++ b/check/classic/classic.exp @@ -660,7 +660,7 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/exported_values/limitations/sigincl/sigincl_lib.ml:9: unit pattern x +./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) diff --git a/check/classic/classic.ref b/check/classic/classic.ref index 35ae2f3..e9fc89c 100644 --- a/check/classic/classic.ref +++ b/check/classic/classic.ref @@ -37,7 +37,7 @@ ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:25: id: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:40: new_method: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:41: public_method_label: Should not be detected -./examples/docs/exported_values/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected +./examples/docs/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj @@ -665,7 +665,7 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/exported_values/limitations/sigincl/sigincl_lib.ml:9: unit pattern x +./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) diff --git a/check/internal/internal.exp b/check/internal/internal.exp index 899c4c9..80705b0 100644 --- a/check/internal/internal.exp +++ b/check/internal/internal.exp @@ -612,7 +612,7 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/exported_values/limitations/sigincl/sigincl_lib.ml:9: unit pattern x +./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) diff --git a/check/internal/internal.ref b/check/internal/internal.ref index 5c83976..f443ef5 100644 --- a/check/internal/internal.ref +++ b/check/internal/internal.ref @@ -27,7 +27,7 @@ ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:25: id: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:40: new_method: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:41: public_method_label: Should not be detected -./examples/docs/exported_values/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected +./examples/docs/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj @@ -617,7 +617,7 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/exported_values/limitations/sigincl/sigincl_lib.ml:9: unit pattern x +./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) diff --git a/check/threshold-1/threshold-1.exp b/check/threshold-1/threshold-1.exp index 64e180d..35bfcec 100644 --- a/check/threshold-1/threshold-1.exp +++ b/check/threshold-1/threshold-1.exp @@ -1068,7 +1068,7 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/exported_values/limitations/sigincl/sigincl_lib.ml:9: unit pattern x +./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) diff --git a/check/threshold-1/threshold-1.ref b/check/threshold-1/threshold-1.ref index ada8803..32be5f8 100644 --- a/check/threshold-1/threshold-1.ref +++ b/check/threshold-1/threshold-1.ref @@ -27,7 +27,7 @@ ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:25: id: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:40: new_method: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:41: public_method_label: Should not be detected -./examples/docs/exported_values/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected +./examples/docs/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj @@ -1073,7 +1073,7 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/exported_values/limitations/sigincl/sigincl_lib.ml:9: unit pattern x +./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) 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 45a54fa..4e7a2fb 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.exp +++ b/check/threshold-3-0.5/threshold-3-0.5.exp @@ -1476,7 +1476,7 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/exported_values/limitations/sigincl/sigincl_lib.ml:9: unit pattern x +./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) 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 3868976..b48fefc 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.ref +++ b/check/threshold-3-0.5/threshold-3-0.5.ref @@ -27,7 +27,7 @@ ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:25: id: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:40: new_method: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:41: public_method_label: Should not be detected -./examples/docs/exported_values/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected +./examples/docs/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj @@ -1477,7 +1477,7 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/exported_values/limitations/sigincl/sigincl_lib.ml:9: unit pattern x +./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) diff --git a/docs/LIMITATIONS.md b/docs/LIMITATIONS.md new file mode 100644 index 0000000..7063a42 --- /dev/null +++ b/docs/LIMITATIONS.md @@ -0,0 +1,111 @@ +# Table of contents + ++ [Module type](#module-type) ++ [Include module type with substitution](#include-module-type-with-substitution) + +The limitations listed below apply to all the reportable elements of code. +Coding style issues are not concerned unless specified otherwise. + +# Module type + +Related issue : +[issue #50](https://github.com/LexiFi/dead_code_analyzer/issues/50). + +As explained in the +[exported values' Module type](./exported_values/code_constructs/MODTYP.md) +example, the analyzer is currently restrcited to not reporting values declared +in module types. This is actually true for all reportable elements of code. +This means that any unused element defined by a module with a module type as +signature, even with constraints or substitutions, will not be reported. + +A future improvement would be to report unused elements declared in module types +by considering all the elemnts defined in modules of such types as instances +of the elements in the module types. + +# Include module type with substitution + +Related issue : +[issue #64](https://github.com/LexiFi/dead_code_analyzer/issues/64). + +According to the above limitation on elements in module types, elements included +from a module type should not be reported. Even more so according to the +semantics described in the +[exported values' Include](./exported_values/code_constructs/INCLUDE.md) +example. +This is the case unless there is a substitution on the module type. + +## Example + +The reference files for this example are in the +[sigincl](../../examples/docs/limitations/sigincl) directory. + +The reference takes place in `/tmp/docs/limitations`, which +is a copy of the [limitations](../../examples/docs/limitations) directory. +Reported locations may differ depending on the location of the source files. + +The compilation command is : +``` +make -C sigincl build +``` + +The analysis command is : +``` +make -C sigincl analyze +``` + +The compile + analyze command is : +``` +make -C sigincl +``` + +Code: +```OCaml +(* sigincl_lib.mli *) +module type T = sig + type t + val x : t +end + +module M : T + +module I : sig + include T with type t := unit +end +``` +```OCaml +(* sigincl_lib.ml *) +module type T = sig + type t + val x : t +end + +module M = struct + type t = unit + let x = () +end + +module I = M +``` + +Compile and analyze: +``` +$ make -C sigincl +make: Entering directory '/tmp/docs/limitations/sigincl' +ocamlopt -bin-annot sigincl_lib.mli sigincl_lib.ml +dead_code_analyzer --nothing -E all . +Scanning files... + [DONE] + +.> UNUSED EXPORTED VALUES: +========================= +/tmp/docs/limitations/sigincl/sigincl_lib.mli:10: I.x + +Nothing else to report in this section +-------------------------------------------------------------------------------- + + +make: Leaving directory '/tmp/docs/limitations/sigincl' +``` + +The analyzer reports `I.x` at the line where `T` is included although it is +actually declared in `T`. diff --git a/docs/USER_DOC.md b/docs/USER_DOC.md index 6d69e26..84d56ee 100644 --- a/docs/USER_DOC.md +++ b/docs/USER_DOC.md @@ -58,6 +58,7 @@ This documentation is split accross different topics: - [Constructors/Record fields](fields_and_constructors/FIELDS_AND_CONSTRUCTORS.md) describes the semantics and usage of the "unused constructors/record fields" report section, and provides examples. - [Optional arguments](optional_arguments/OPTIONAL_ARGUMENTS.md) describes the semantics and usage of the optional arguments always/never used report sections, and provides examples. - [Coding style](coding_style/CODING_STYLE.md) describes the semantics and usage of the "coding style" report section, and provides examples. +- [Limitations](LIMITATIONS.md) describes overall limitations of the `dead_code_analyzer`, and provides examples. ## Footnotes diff --git a/docs/exported_values/EXPORTED_VALUES.md b/docs/exported_values/EXPORTED_VALUES.md index bff356f..4cf21af 100644 --- a/docs/exported_values/EXPORTED_VALUES.md +++ b/docs/exported_values/EXPORTED_VALUES.md @@ -9,8 +9,6 @@ + [Usage](#usage) + [Examples](#examples) + [Limitations](#limitations) - + [Module type](#module-type) - + [Include module type with substitution](#include-module-type-with-substitution) + [Including a module with same name](#including-a-module-with-the-same-name) # Exported Values @@ -232,107 +230,6 @@ Warning 26 [unused-var]: unused variable y. # Limitations -## Module type - -Related issue : -[issue #50](https://github.com/LexiFi/dead_code_analyzer/issues/50). - -As explained in the [Module type](./code_constructs/MODTYP.md) example, the -analyzer is currently restrcited to not reporting values declared in module -types. This means that any unused value defined by a module with a module type -as signature, even with constraints or substitutions, will not be reported. - -A future improvement would be to report unused exported values declared in -module types by considering all the values defined in modules of such types as -instances of the values in the module types. - -## Include module type with substitution - -Related issue : -[issue #64](https://github.com/LexiFi/dead_code_analyzer/issues/64). - -According to the above limitation on values in module types, values included -from a module type should not be reported. Even more so according to the -semantics described in the [Include](./code_constructs/INCLUDE.md) example. -This is the case unless there is a substitution on the module type. - -### Example - -The reference files for this example are in the -[sigincl](../../examples/docs/exported_values/limitations/sigincl) directory. - -The reference takes place in `/tmp/docs/exported_values/limitations`, which -is a copy of the [limitations](../../examples/docs/exported_values/limitations) -directory. Reported locations may differ depending on the location of the source -files. - -The compilation command is : -``` -make -C sigincl build -``` - -The analysis command is : -``` -make -C sigincl analyze -``` - -The compile + analyze command is : -``` -make -C sigincl -``` - -Code: -```OCaml -(* sigincl_lib.mli *) -module type T = sig - type t - val x : t -end - -module M : T - -module I : sig - include T with type t := unit -end -``` -```OCaml -(* sigincl_lib.ml *) -module type T = sig - type t - val x : t -end - -module M = struct - type t = unit - let x = () -end - -module I = M -``` - -Compile and analyze: -``` -$ make -C sigincl -make: Entering directory '/tmp/docs/exported_values/limitations/sigincl' -ocamlopt -bin-annot sigincl_lib.mli sigincl_lib.ml -dead_code_analyzer --nothing -E all . -Scanning files... - [DONE] - -.> UNUSED EXPORTED VALUES: -========================= -/tmp/docs/exported_values/limitations/sigincl/sigincl_lib.mli:10: I.x - -Nothing else to report in this section --------------------------------------------------------------------------------- - - -make: Leaving directory '/tmp/docs/exported_values/limitations/sigincl' -``` - -The analyzer reports `I.x` at the line where `T` is included although it is -actually declared in `T`. - ## Including a module with the same name Related issue : diff --git a/examples/docs/Makefile b/examples/docs/Makefile index 87e4dab..d165abe 100644 --- a/examples/docs/Makefile +++ b/examples/docs/Makefile @@ -8,6 +8,7 @@ build: make -C fields_and_constructors make -C optional_arguments make -C coding_style + make -C limitations clean: rm -f *~ *.cm* *.o *.obj @@ -16,4 +17,5 @@ clean: make -C fields_and_constructors clean make -C optional_arguments clean make -C coding_style clean + make -C limitations clean diff --git a/examples/docs/exported_values/limitations/Makefile b/examples/docs/exported_values/limitations/Makefile index e54f633..532d49c 100644 --- a/examples/docs/exported_values/limitations/Makefile +++ b/examples/docs/exported_values/limitations/Makefile @@ -3,10 +3,8 @@ all: build build: - make -C sigincl build make -C incl_same_name build clean: rm -f *~ *.cm* *.o *.obj - make -C sigincl clean make -C incl_same_name clean diff --git a/examples/docs/limitations/Makefile b/examples/docs/limitations/Makefile new file mode 100644 index 0000000..d712a36 --- /dev/null +++ b/examples/docs/limitations/Makefile @@ -0,0 +1,10 @@ +.PHONY: clean build + +all: build + +build: + make -C sigincl build + +clean: + rm -f *~ *.cm* *.o *.obj + make -C sigincl clean diff --git a/examples/docs/exported_values/limitations/sigincl/Makefile b/examples/docs/limitations/sigincl/Makefile similarity index 77% rename from examples/docs/exported_values/limitations/sigincl/Makefile rename to examples/docs/limitations/sigincl/Makefile index faff194..570c445 100644 --- a/examples/docs/exported_values/limitations/sigincl/Makefile +++ b/examples/docs/limitations/sigincl/Makefile @@ -6,7 +6,7 @@ build: ocamlopt -bin-annot ${SRC} analyze: - dead_code_analyzer --nothing -E all . + dead_code_analyzer . clean: rm -f *.cm* *.o a.out diff --git a/examples/docs/exported_values/limitations/sigincl/sigincl_lib.ml b/examples/docs/limitations/sigincl/sigincl_lib.ml similarity index 100% rename from examples/docs/exported_values/limitations/sigincl/sigincl_lib.ml rename to examples/docs/limitations/sigincl/sigincl_lib.ml diff --git a/examples/docs/exported_values/limitations/sigincl/sigincl_lib.mli b/examples/docs/limitations/sigincl/sigincl_lib.mli similarity index 100% rename from examples/docs/exported_values/limitations/sigincl/sigincl_lib.mli rename to examples/docs/limitations/sigincl/sigincl_lib.mli From fbd4521f3d227af5385190bd2e1f3d641721f5fb Mon Sep 17 00:00:00 2001 From: Corentin De Souza <9597216+fantazio@users.noreply.github.com> Date: Mon, 3 Aug 2026 14:04:49 +0200 Subject: [PATCH 3/3] [examples][docs][limitations] move and generalize sigincl into modtype Extend the test to all supported constructs. It now shows the limitation on constructors, fields, methods, and optional values. The documentation, expected, and ref results have been updated accordingly. --- check/classic/classic.exp | 2 - check/classic/classic.ref | 63 ++++- check/internal/internal.exp | 2 - check/internal/internal.ref | 63 ++++- check/threshold-1/threshold-1.exp | 2 - check/threshold-1/threshold-1.ref | 63 ++++- check/threshold-3-0.5/threshold-3-0.5.exp | 2 - check/threshold-3-0.5/threshold-3-0.5.ref | 73 ++++- docs/LIMITATIONS.md | 251 +++++++++++++++--- examples/docs/limitations/Makefile | 4 +- examples/docs/limitations/modtype/Makefile | 12 + .../docs/limitations/modtype/modtype_bin.ml | 29 ++ .../limitations/modtype/modtype_with_intf.ml | 111 ++++++++ .../limitations/modtype/modtype_with_intf.mli | 36 +++ .../modtype/modtype_without_intf.ml | 117 ++++++++ examples/docs/limitations/sigincl/Makefile | 12 - .../docs/limitations/sigincl/sigincl_lib.ml | 12 - .../docs/limitations/sigincl/sigincl_lib.mli | 11 - 18 files changed, 761 insertions(+), 104 deletions(-) create mode 100644 examples/docs/limitations/modtype/Makefile create mode 100644 examples/docs/limitations/modtype/modtype_bin.ml create mode 100644 examples/docs/limitations/modtype/modtype_with_intf.ml create mode 100644 examples/docs/limitations/modtype/modtype_with_intf.mli create mode 100644 examples/docs/limitations/modtype/modtype_without_intf.ml delete mode 100644 examples/docs/limitations/sigincl/Makefile delete mode 100644 examples/docs/limitations/sigincl/sigincl_lib.ml delete mode 100644 examples/docs/limitations/sigincl/sigincl_lib.mli diff --git a/check/classic/classic.exp b/check/classic/classic.exp index 84fd0e4..f46f87e 100644 --- a/check/classic/classic.exp +++ b/check/classic/classic.exp @@ -660,8 +660,6 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x - ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) diff --git a/check/classic/classic.ref b/check/classic/classic.ref index e9fc89c..5fda775 100644 --- a/check/classic/classic.ref +++ b/check/classic/classic.ref @@ -37,7 +37,6 @@ ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:25: id: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:40: new_method: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:41: public_method_label: Should not be detected -./examples/docs/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj @@ -171,6 +170,34 @@ Nothing else to report in this section .> UNUSED METHODS: ================= +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: Ftor_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: Incl.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: Incl_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: With.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: Ftor_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: Incl.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: Incl_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: With.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: Ftor_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: Incl.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: Incl_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: With.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: Ftor_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: Incl.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: Incl_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: With.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.o#m: Should not be detected ./examples/docs/methods/code_constructs/class/class_bin.ml:2: unused_class#unused_method ./examples/docs/methods/code_constructs/class/class_lib.mli:2: int_stack#reset @@ -264,6 +291,14 @@ Nothing else to report in this section ./examples/docs/fields_and_constructors/code_constructs/polymorphic_type/polymorphic_type_lib.mli:2: either.Right ./examples/docs/fields_and_constructors/code_constructs/polymorphic_type/polymorphic_type_lib.mli:3: both.left +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: Ftor_with.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: Incl.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: Incl_with.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: With.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: Ftor_with.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: Incl.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: Incl_with.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: With.field.field: Should not be detected ./examples/using_dune/preprocessed_lib/preprocessed.mli:14: constructors.Unused ./examples/using_dune/preprocessed_lib/preprocessed.mli:19: constr_with_eq.Unused ./examples/using_dune/preprocessed_lib/preprocessed.mli:23: record.unused @@ -340,6 +375,14 @@ Nothing else to report in this section ============================= ./examples/docs/coding_style/opt/opt.ml:15: ?index +./examples/docs/limitations/modtype/modtype_with_intf.mli:9: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:9: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: ?always: Should not be detected ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:3: ?max ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: ?index @@ -501,6 +544,14 @@ Nothing else to report in this section .> OPTIONAL ARGUMENTS: NEVER: ============================ +./examples/docs/limitations/modtype/modtype_with_intf.mli:9: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:9: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: ?never: Should not be detected ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:2: ?min ./examples/docs/optional_arguments/code_constructs/internal_app/internal_app_lib.ml:2: ?min @@ -665,8 +716,6 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x - ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) @@ -719,7 +768,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 593 -Success: 586 -Failed: 7 -Ratio: 98.8195615514% +Total: 643 +Success: 585 +Failed: 58 +Ratio: 90.9797822706% diff --git a/check/internal/internal.exp b/check/internal/internal.exp index 80705b0..3f47d1c 100644 --- a/check/internal/internal.exp +++ b/check/internal/internal.exp @@ -612,8 +612,6 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x - ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) diff --git a/check/internal/internal.ref b/check/internal/internal.ref index f443ef5..2dadd91 100644 --- a/check/internal/internal.ref +++ b/check/internal/internal.ref @@ -27,7 +27,6 @@ ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:25: id: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:40: new_method: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:41: public_method_label: Should not be detected -./examples/docs/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj @@ -123,6 +122,34 @@ Nothing else to report in this section .> UNUSED METHODS: ================= +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: Ftor_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: Incl.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: Incl_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: With.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: Ftor_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: Incl.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: Incl_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: With.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: Ftor_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: Incl.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: Incl_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: With.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: Ftor_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: Incl.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: Incl_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: With.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.o#m: Should not be detected ./examples/docs/methods/code_constructs/class/class_bin.ml:2: unused_class#unused_method ./examples/docs/methods/code_constructs/class/class_lib.mli:2: int_stack#reset @@ -216,6 +243,14 @@ Nothing else to report in this section ./examples/docs/fields_and_constructors/code_constructs/polymorphic_type/polymorphic_type_lib.mli:2: either.Right ./examples/docs/fields_and_constructors/code_constructs/polymorphic_type/polymorphic_type_lib.mli:3: both.left +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: Ftor_with.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: Incl.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: Incl_with.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: With.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: Ftor_with.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: Incl.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: Incl_with.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: With.field.field: Should not be detected ./examples/using_dune/preprocessed_lib/preprocessed.mli:14: constructors.Unused ./examples/using_dune/preprocessed_lib/preprocessed.mli:19: constr_with_eq.Unused ./examples/using_dune/preprocessed_lib/preprocessed.mli:23: record.unused @@ -292,6 +327,14 @@ Nothing else to report in this section ============================= ./examples/docs/coding_style/opt/opt.ml:15: ?index +./examples/docs/limitations/modtype/modtype_with_intf.mli:9: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:9: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: ?always: Should not be detected ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:3: ?max ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: ?index @@ -453,6 +496,14 @@ Nothing else to report in this section .> OPTIONAL ARGUMENTS: NEVER: ============================ +./examples/docs/limitations/modtype/modtype_with_intf.mli:9: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:9: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: ?never: Should not be detected ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:2: ?min ./examples/docs/optional_arguments/code_constructs/internal_app/internal_app_lib.ml:2: ?min @@ -617,8 +668,6 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x - ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) @@ -671,7 +720,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 549 -Success: 542 -Failed: 7 -Ratio: 98.7249544627% +Total: 599 +Success: 541 +Failed: 58 +Ratio: 90.3171953255% diff --git a/check/threshold-1/threshold-1.exp b/check/threshold-1/threshold-1.exp index 35bfcec..1b9d1dd 100644 --- a/check/threshold-1/threshold-1.exp +++ b/check/threshold-1/threshold-1.exp @@ -1068,8 +1068,6 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x - ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) diff --git a/check/threshold-1/threshold-1.ref b/check/threshold-1/threshold-1.ref index 32be5f8..92c6a0e 100644 --- a/check/threshold-1/threshold-1.ref +++ b/check/threshold-1/threshold-1.ref @@ -27,7 +27,6 @@ ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:25: id: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:40: new_method: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:41: public_method_label: Should not be detected -./examples/docs/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj @@ -405,6 +404,34 @@ Nothing else to report in this section .> UNUSED METHODS: ================= +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: Ftor_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: Incl.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: Incl_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: With.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: Ftor_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: Incl.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: Incl_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: With.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: Ftor_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: Incl.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: Incl_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: With.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: Ftor_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: Incl.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: Incl_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: With.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.o#m: Should not be detected ./examples/docs/methods/code_constructs/class/class_bin.ml:2: unused_class#unused_method ./examples/docs/methods/code_constructs/class/class_lib.mli:2: int_stack#reset @@ -591,6 +618,14 @@ Nothing else to report in this section ./examples/docs/fields_and_constructors/code_constructs/polymorphic_type/polymorphic_type_lib.mli:2: either.Right ./examples/docs/fields_and_constructors/code_constructs/polymorphic_type/polymorphic_type_lib.mli:3: both.left +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: Ftor_with.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: Incl.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: Incl_with.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: With.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: Ftor_with.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: Incl.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: Incl_with.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: With.field.field: Should not be detected ./examples/using_dune/preprocessed_lib/preprocessed.mli:14: constructors.Unused ./examples/using_dune/preprocessed_lib/preprocessed.mli:19: constr_with_eq.Unused ./examples/using_dune/preprocessed_lib/preprocessed.mli:23: record.unused @@ -748,6 +783,14 @@ Nothing else to report in this section ============================= ./examples/docs/coding_style/opt/opt.ml:15: ?index +./examples/docs/limitations/modtype/modtype_with_intf.mli:9: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:9: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: ?always: Should not be detected ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:3: ?max ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: ?index @@ -909,6 +952,14 @@ Nothing else to report in this section .> OPTIONAL ARGUMENTS: NEVER: ============================ +./examples/docs/limitations/modtype/modtype_with_intf.mli:9: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:9: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: ?never: Should not be detected ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:2: ?min ./examples/docs/optional_arguments/code_constructs/internal_app/internal_app_lib.ml:2: ?min @@ -1073,8 +1124,6 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x - ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) @@ -1127,7 +1176,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 929 -Success: 920 -Failed: 9 -Ratio: 99.0312163617% +Total: 979 +Success: 919 +Failed: 60 +Ratio: 93.8712972421% 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 4e7a2fb..b520252 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.exp +++ b/check/threshold-3-0.5/threshold-3-0.5.exp @@ -1476,8 +1476,6 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x - ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) 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 b48fefc..1f4f76c 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.ref +++ b/check/threshold-3-0.5/threshold-3-0.5.ref @@ -27,7 +27,6 @@ ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:25: id: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:40: new_method: Should not be detected ./examples/docs/exported_values/limitations/incl_same_name/oo.mli:41: public_method_label: Should not be detected -./examples/docs/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj @@ -407,6 +406,10 @@ ./examples/docs/exported_values/hello_world/hello_world_with_intf.mli:4: world ./examples/docs/exported_values/hello_world/hello_world_without_intf.ml:4: world +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.always: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.f: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.o: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.x: Should not be detected ./examples/docs/methods/limitations/alias/alias_lib.mli:2: original ./examples/docs/optional_arguments/code_constructs/intext_app/intext_app_lib.mli:2: max @@ -548,6 +551,34 @@ Nothing else to report in this section .> UNUSED METHODS: ================= +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: Ftor_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: Incl.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: Incl_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:7: With.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: Ftor_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: Incl.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: Incl_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:8: With.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: Ftor_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: Incl.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: Incl_with.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:7: With.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: Ftor_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: Incl.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: Incl_with.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:8: With.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.o#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.c#m: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.o#m: Should not be detected ./examples/docs/methods/code_constructs/class/class_bin.ml:2: unused_class#unused_method ./examples/docs/methods/code_constructs/class/class_lib.mli:2: int_stack#reset @@ -773,6 +804,14 @@ Nothing else to report in this section ./examples/docs/fields_and_constructors/code_constructs/polymorphic_type/polymorphic_type_lib.mli:2: either.Right ./examples/docs/fields_and_constructors/code_constructs/polymorphic_type/polymorphic_type_lib.mli:3: both.left +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: Ftor_with.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: Incl.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: Incl_with.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:4: With.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: Ftor_with.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: Incl.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: Incl_with.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:5: With.field.field: Should not be detected ./examples/using_dune/preprocessed_lib/preprocessed.mli:14: constructors.Unused ./examples/using_dune/preprocessed_lib/preprocessed.mli:19: constr_with_eq.Unused ./examples/using_dune/preprocessed_lib/preprocessed.mli:23: record.unused @@ -926,6 +965,12 @@ Nothing else to report in this section .>-> ALMOST UNUSED CONSTRUCTORS/RECORD FIELDS: Called 2 time(s): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.field.field: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.ctor.Ctor: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.field.field: Should not be detected ./examples/using_dune/preprocessed_lib/preprocessed.mli:15: constructors.Used ./examples/using_dune/preprocessed_lib/preprocessed.mli:24: record.used ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:26: constructors.Used @@ -973,6 +1018,14 @@ Nothing else to report in this section ============================= ./examples/docs/coding_style/opt/opt.ml:15: ?index +./examples/docs/limitations/modtype/modtype_with_intf.mli:9: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:9: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: ?always: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: ?always: Should not be detected ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:3: ?max ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: ?index @@ -1231,6 +1284,14 @@ Nothing else to report in this section .> OPTIONAL ARGUMENTS: NEVER: ============================ +./examples/docs/limitations/modtype/modtype_with_intf.mli:9: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:18: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:29: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_with_intf.mli:36: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:9: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:36: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:74: ?never: Should not be detected +./examples/docs/limitations/modtype/modtype_without_intf.ml:108: ?never: Should not be detected ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:2: ?min ./examples/docs/optional_arguments/code_constructs/internal_app/internal_app_lib.ml:2: ?min @@ -1477,8 +1538,6 @@ Nothing else to report in this section ./examples/docs/exported_values/code_constructs/module/module_lib.ml:6: unit pattern unused ./examples/docs/exported_values/code_constructs/module/module_lib.ml:7: unit pattern unused_unexported -./examples/docs/limitations/sigincl/sigincl_lib.ml:9: unit pattern x - ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:3: let x = ... in x (=> useless binding) ./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:12: let x = ... in x (=> useless binding) @@ -1531,7 +1590,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 1251 -Success: 1242 -Failed: 9 -Ratio: 99.2805755396% +Total: 1311 +Success: 1241 +Failed: 70 +Ratio: 94.6605644546% diff --git a/docs/LIMITATIONS.md b/docs/LIMITATIONS.md index 7063a42..30c78de 100644 --- a/docs/LIMITATIONS.md +++ b/docs/LIMITATIONS.md @@ -1,7 +1,7 @@ # Table of contents + [Module type](#module-type) -+ [Include module type with substitution](#include-module-type-with-substitution) ++ [Module type with and inclusion](#module-type-with-and-inclusion) The limitations listed below apply to all the reportable elements of code. Coding style issues are not concerned unless specified otherwise. @@ -22,22 +22,30 @@ A future improvement would be to report unused elements declared in module types by considering all the elemnts defined in modules of such types as instances of the elements in the module types. -# Include module type with substitution +# Module type with and inclusion Related issue : [issue #64](https://github.com/LexiFi/dead_code_analyzer/issues/64). According to the above limitation on elements in module types, elements included -from a module type should not be reported. Even more so according to the -semantics described in the +from a module type (`include T`) should not be reported. Even more so according +to the semantics described in the [exported values' Include](./exported_values/code_constructs/INCLUDE.md) example. -This is the case unless there is a substitution on the module type. +Similarly, elements defined in a module type with constraints (`T with ...`) +should not be reported. + +This is mostly the case for unused exported values, unless there is a substition +(`T with ... := ...`) and not .mli is provided, or a .mli is provided and the 2 +contructs are mixed into an included module type with substitution +(`include T with ... := ...`). +This is however, not the case at all for constructors, fields, and methods. +Optional arguments always/never used are only affected by substitutions. ## Example The reference files for this example are in the -[sigincl](../../examples/docs/limitations/sigincl) directory. +[modtype](../../examples/docs/limitations/modtype) directory. The reference takes place in `/tmp/docs/limitations`, which is a copy of the [limitations](../../examples/docs/limitations) directory. @@ -45,67 +53,248 @@ Reported locations may differ depending on the location of the source files. The compilation command is : ``` -make -C sigincl build +make -C modtype build ``` The analysis command is : ``` -make -C sigincl analyze +make -C modtype analyze ``` The compile + analyze command is : ``` -make -C sigincl +make -C modtype ``` Code: ```OCaml -(* sigincl_lib.mli *) +(* modtype_with_intf.mli *) module type T = sig type t + type ctor = Ctor + type field = {field : unit} val x : t + val o : < m : t > + class c : object method m : t end + val f : ?always:t -> ?never:t -> unit -> t + (* to use as [always] in call to [f] *) + val always : t end -module M : T +module Regular : T + +module With : T with type t = int -module I : sig - include T with type t := unit +module Subst : T with type t := int + +module Incl : sig + include T end -``` -```OCaml -(* sigincl_lib.ml *) -module type T = sig - type t - val x : t + +module Incl_with : sig + include T with type t = int end -module M = struct - type t = unit - let x = () +module Incl_subst : sig + include T with type t := int end -module I = M +module Ftor () : T + +module Ftor_with () : T with type t = int + +module Ftor_subst () : T with type t := int +``` +The other files are not displayed here. +`modtype_without_intf` is equivalent to `modtype_with_intf`'s interface and +implementation merged together. `modtype_bin` uses the function's `f` to track +its optional parameters. +The modules are all defined as: +```OCaml +struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end ``` Compile and analyze: ``` -$ make -C sigincl -make: Entering directory '/tmp/docs/limitations/sigincl' -ocamlopt -bin-annot sigincl_lib.mli sigincl_lib.ml -dead_code_analyzer --nothing -E all . +$ make -C modtype +make: Entering directory '/tmp/docs/limitations/modtype' +ocamlopt -bin-annot modtype_with_intf.mli modtype_with_intf.ml modtype_without_intf.ml modtype_bin.ml +dead_code_analyzer --all -E threshold:4 -M threshold:4 -T threshold:4 . Scanning files... [DONE] .> UNUSED EXPORTED VALUES: ========================= -/tmp/docs/limitations/sigincl/sigincl_lib.mli:10: I.x + + +.>-> ALMOST UNUSED EXPORTED VALUES: Called 2 time(s): +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +/tmp/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.always +/tmp/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.f +/tmp/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.o +/tmp/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.x +-------- + + +.>-> ALMOST UNUSED EXPORTED VALUES: Called 4 time(s): +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +/tmp/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.always +/tmp/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.f +/tmp/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.o +/tmp/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.x +/tmp/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.always +/tmp/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.f +/tmp/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.o +/tmp/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.x +/tmp/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.always +/tmp/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.f +/tmp/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.o +/tmp/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.x + +Nothing else to report in this section +-------------------------------------------------------------------------------- + + +.> UNUSED METHODS: +================= +/tmp/docs/limitations/modtype/modtype_with_intf.mli:7: Ftor_with.o#m +/tmp/docs/limitations/modtype/modtype_with_intf.mli:7: Incl.o#m +/tmp/docs/limitations/modtype/modtype_with_intf.mli:7: Incl_with.o#m +/tmp/docs/limitations/modtype/modtype_with_intf.mli:7: With.o#m +/tmp/docs/limitations/modtype/modtype_with_intf.mli:8: Ftor_with.c#m +/tmp/docs/limitations/modtype/modtype_with_intf.mli:8: Incl.c#m +/tmp/docs/limitations/modtype/modtype_with_intf.mli:8: Incl_with.c#m +/tmp/docs/limitations/modtype/modtype_with_intf.mli:8: With.c#m +/tmp/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.c#m +/tmp/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.o#m +/tmp/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.c#m +/tmp/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.o#m +/tmp/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.c#m +/tmp/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.o#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:7: Ftor_with.o#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:7: Incl.o#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:7: Incl_with.o#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:7: With.o#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:8: Ftor_with.c#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:8: Incl.c#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:8: Incl_with.c#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:8: With.c#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.c#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.o#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.c#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.o#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.c#m +/tmp/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.o#m +-------- + + + +Nothing else to report in this section +-------------------------------------------------------------------------------- + + +.> UNUSED CONSTRUCTORS/RECORD FIELDS: +==================================== +/tmp/docs/limitations/modtype/modtype_with_intf.mli:4: Ftor_with.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_with_intf.mli:4: Incl.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_with_intf.mli:4: Incl_with.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_with_intf.mli:4: With.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_with_intf.mli:5: Ftor_with.field.field +/tmp/docs/limitations/modtype/modtype_with_intf.mli:5: Incl.field.field +/tmp/docs/limitations/modtype/modtype_with_intf.mli:5: Incl_with.field.field +/tmp/docs/limitations/modtype/modtype_with_intf.mli:5: With.field.field +-------- + + +.>-> ALMOST UNUSED CONSTRUCTORS/RECORD FIELDS: Called 2 time(s): +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +/tmp/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_with_intf.mli:18: Subst.field.field +/tmp/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_with_intf.mli:29: Incl_subst.field.field +/tmp/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_with_intf.mli:36: Ftor_subst.field.field +-------- + + +.>-> ALMOST UNUSED CONSTRUCTORS/RECORD FIELDS: Called 4 time(s): +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +/tmp/docs/limitations/modtype/modtype_without_intf.ml:4: Ftor_with.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_without_intf.ml:4: Incl.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_without_intf.ml:4: Incl_with.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_without_intf.ml:4: With.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_without_intf.ml:5: Ftor_with.field.field +/tmp/docs/limitations/modtype/modtype_without_intf.ml:5: Incl.field.field +/tmp/docs/limitations/modtype/modtype_without_intf.ml:5: Incl_with.field.field +/tmp/docs/limitations/modtype/modtype_without_intf.ml:5: With.field.field +/tmp/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_without_intf.ml:36: Subst.field.field +/tmp/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_without_intf.ml:74: Incl_subst.field.field +/tmp/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.ctor.Ctor +/tmp/docs/limitations/modtype/modtype_without_intf.ml:108: Ftor_subst.field.field + +Nothing else to report in this section +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- + + +.> OPTIONAL ARGUMENTS: ALWAYS: +============================= +/tmp/docs/limitations/modtype/modtype_with_intf.mli:9: ?always +/tmp/docs/limitations/modtype/modtype_with_intf.mli:18: ?always +/tmp/docs/limitations/modtype/modtype_with_intf.mli:29: ?always +/tmp/docs/limitations/modtype/modtype_with_intf.mli:36: ?always +/tmp/docs/limitations/modtype/modtype_without_intf.ml:9: ?always +/tmp/docs/limitations/modtype/modtype_without_intf.ml:36: ?always +/tmp/docs/limitations/modtype/modtype_without_intf.ml:74: ?always +/tmp/docs/limitations/modtype/modtype_without_intf.ml:108: ?always + +Nothing else to report in this section +-------------------------------------------------------------------------------- + + +.> OPTIONAL ARGUMENTS: NEVER: +============================ +/tmp/docs/limitations/modtype/modtype_with_intf.mli:9: ?never +/tmp/docs/limitations/modtype/modtype_with_intf.mli:18: ?never +/tmp/docs/limitations/modtype/modtype_with_intf.mli:29: ?never +/tmp/docs/limitations/modtype/modtype_with_intf.mli:36: ?never +/tmp/docs/limitations/modtype/modtype_without_intf.ml:9: ?never +/tmp/docs/limitations/modtype/modtype_without_intf.ml:36: ?never +/tmp/docs/limitations/modtype/modtype_without_intf.ml:74: ?never +/tmp/docs/limitations/modtype/modtype_without_intf.ml:108: ?never + +Nothing else to report in this section +-------------------------------------------------------------------------------- + + +.> CODING STYLE: +=============== Nothing else to report in this section -------------------------------------------------------------------------------- -make: Leaving directory '/tmp/docs/limitations/sigincl' +make: Leaving directory '/tmp/docs/limitations/modtype' ``` +> [!NOTE] +> The analyzer is run with thresholds. Because elements of `T` share the same +> location at the point of use of `T`, the analyzer gets confused and considers +> some unused elements as used. Using thresholds enables reporting elements used +> up to a fixed amount. +> For more details about the command line arguments see [the more general Usage +documentation](../USAGE.md). -The analyzer reports `I.x` at the line where `T` is included although it is -actually declared in `T`. +The analyzer reports elements although they are all defined within module type +`T`. +Following its semantics on module types, the report should be empty. diff --git a/examples/docs/limitations/Makefile b/examples/docs/limitations/Makefile index d712a36..b14152c 100644 --- a/examples/docs/limitations/Makefile +++ b/examples/docs/limitations/Makefile @@ -3,8 +3,8 @@ all: build build: - make -C sigincl build + make -C modtype build clean: rm -f *~ *.cm* *.o *.obj - make -C sigincl clean + make -C modtype clean diff --git a/examples/docs/limitations/modtype/Makefile b/examples/docs/limitations/modtype/Makefile new file mode 100644 index 0000000..e2d7de8 --- /dev/null +++ b/examples/docs/limitations/modtype/Makefile @@ -0,0 +1,12 @@ +SRC:=modtype_with_intf.mli modtype_with_intf.ml modtype_without_intf.ml modtype_bin.ml + +all: build analyze + +build: + ocamlopt -bin-annot ${SRC} + +analyze: + dead_code_analyzer --all -E threshold:4 -M threshold:4 -T threshold:4 . + +clean: + rm -f *.cm* *.o a.out diff --git a/examples/docs/limitations/modtype/modtype_bin.ml b/examples/docs/limitations/modtype/modtype_bin.ml new file mode 100644 index 0000000..9759f41 --- /dev/null +++ b/examples/docs/limitations/modtype/modtype_bin.ml @@ -0,0 +1,29 @@ +module M_intf = Modtype_with_intf.Ftor () +module M_intf_with = Modtype_with_intf.Ftor_with () +module M_intf_subst = Modtype_with_intf.Ftor_subst () + +let () = + let open Modtype_with_intf in + With.(f ~always ()) |> ignore; + Subst.(f ~always ()) |> ignore; + Incl.(f ~always ()) |> ignore; + Incl_with.(f ~always ()) |> ignore; + Incl_subst.f ~always:Incl_subst.always () |> ignore; + M_intf.(f ~always ()) |> ignore; + M_intf_with.(f ~always ()) |> ignore; + M_intf_subst.(f ~always ()) |> ignore + +module M_no_intf = Modtype_without_intf.Ftor () +module M_no_intf_with = Modtype_without_intf.Ftor_with () +module M_no_intf_subst = Modtype_without_intf.Ftor_subst () + +let () = + let open Modtype_without_intf in + With.(f ~always ()) |> ignore; + Subst.(f ~always ()) |> ignore; + Incl.(f ~always ()) |> ignore; + Incl_with.(f ~always ()) |> ignore; + Incl_subst.f ~always:Incl_subst.always () |> ignore; + M_no_intf.(f ~always ()) |> ignore; + M_no_intf_with.(f ~always ()) |> ignore; + M_no_intf_subst.(f ~always ()) |> ignore diff --git a/examples/docs/limitations/modtype/modtype_with_intf.ml b/examples/docs/limitations/modtype/modtype_with_intf.ml new file mode 100644 index 0000000..364caf7 --- /dev/null +++ b/examples/docs/limitations/modtype/modtype_with_intf.ml @@ -0,0 +1,111 @@ +(* modtype_with_intf.mli *) +module type T = sig + type t + type ctor = Ctor + type field = {field : unit} + val x : t + val o : < m : t > + class c : object method m : t end + val f : ?always:t -> ?never:t -> unit -> t + (* to use as [always] in call to [f] *) + val always : t +end + +module Regular = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module With = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Subst = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Incl = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Incl_with = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Incl_subst = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Ftor() = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Ftor_with() = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Ftor_subst() = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end diff --git a/examples/docs/limitations/modtype/modtype_with_intf.mli b/examples/docs/limitations/modtype/modtype_with_intf.mli new file mode 100644 index 0000000..8b68861 --- /dev/null +++ b/examples/docs/limitations/modtype/modtype_with_intf.mli @@ -0,0 +1,36 @@ +(* modtype_with_intf.mli *) +module type T = sig + type t + type ctor = Ctor + type field = {field : unit} + val x : t + val o : < m : t > + class c : object method m : t end + val f : ?always:t -> ?never:t -> unit -> t + (* to use as [always] in call to [f] *) + val always : t +end + +module Regular : T + +module With : T with type t = int + +module Subst : T with type t := int + +module Incl : sig + include T +end + +module Incl_with : sig + include T with type t = int +end + +module Incl_subst : sig + include T with type t := int +end + +module Ftor () : T + +module Ftor_with () : T with type t = int + +module Ftor_subst () : T with type t := int diff --git a/examples/docs/limitations/modtype/modtype_without_intf.ml b/examples/docs/limitations/modtype/modtype_without_intf.ml new file mode 100644 index 0000000..073d259 --- /dev/null +++ b/examples/docs/limitations/modtype/modtype_without_intf.ml @@ -0,0 +1,117 @@ +(* modtype_without_intf.ml *) +module type T = sig + type t + type ctor = Ctor + type field = {field : unit} + val x : t + val o : < m : t > + class c : object method m : t end + val f : ?always:t -> ?never:t -> unit -> t + (* to use as [always] in call to [f] *) + val always : t +end + +module Regular : T = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module With : T with type t = int = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Subst : T with type t := int = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Incl : sig + include T +end = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Incl_with : sig + include T with type t = int +end = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Incl_subst : sig + include T with type t := int +end = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Ftor() : T = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Ftor_with() : T with type t = int = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end + +module Ftor_subst() : T with type t := int = struct + type t = int + type ctor = Ctor + type field = {field : unit} + let x = 0 + let o = object method m = 0 end + class c = object method m = 0 end + let f ?always:_ ?never:_ () = 0 + let always = 0 +end diff --git a/examples/docs/limitations/sigincl/Makefile b/examples/docs/limitations/sigincl/Makefile deleted file mode 100644 index 570c445..0000000 --- a/examples/docs/limitations/sigincl/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -SRC:=sigincl_lib.mli sigincl_lib.ml - -all: build analyze - -build: - ocamlopt -bin-annot ${SRC} - -analyze: - dead_code_analyzer . - -clean: - rm -f *.cm* *.o a.out diff --git a/examples/docs/limitations/sigincl/sigincl_lib.ml b/examples/docs/limitations/sigincl/sigincl_lib.ml deleted file mode 100644 index f30d134..0000000 --- a/examples/docs/limitations/sigincl/sigincl_lib.ml +++ /dev/null @@ -1,12 +0,0 @@ -(* sigincl_lib.ml *) -module type T = sig - type t - val x : t -end - -module M = struct - type t = unit - let x = () -end - -module I = M diff --git a/examples/docs/limitations/sigincl/sigincl_lib.mli b/examples/docs/limitations/sigincl/sigincl_lib.mli deleted file mode 100644 index a0c32a3..0000000 --- a/examples/docs/limitations/sigincl/sigincl_lib.mli +++ /dev/null @@ -1,11 +0,0 @@ -(* sigincl_lib.mli *) -module type T = sig - type t - val x : t -end - -module M : T - -module I : sig - include T with type t := unit -end