From 603ded9bb51de0969f41afe0682d6cef5feed98c Mon Sep 17 00:00:00 2001 From: Corentin De Souza <9597216+fantazio@users.noreply.github.com> Date: Fri, 21 Aug 2026 18:34:40 +0200 Subject: [PATCH 1/3] [examples][docs][methods] improve factory_dun_indir The limitation was only testing for a single unused method. Now it tests methods unused, used locally, and methods used outside the factory. --- check/classic/classic.exp | 10 +++---- check/classic/classic.ref | 16 +++++------- check/internal/internal.exp | 10 +++---- check/internal/internal.ref | 16 +++++------- check/threshold-1/threshold-1.exp | 17 +++++++----- check/threshold-1/threshold-1.ref | 24 +++++++++-------- check/threshold-3-0.5/threshold-3-0.5.exp | 17 +++++++----- check/threshold-3-0.5/threshold-3-0.5.ref | 24 +++++++++-------- .../factory_fun_indir/factory_fun_indir.ml | 26 ++++++++++++++++--- 9 files changed, 86 insertions(+), 74 deletions(-) diff --git a/check/classic/classic.exp b/check/classic/classic.exp index 6ed8bc5b..9b63431c 100644 --- a/check/classic/classic.exp +++ b/check/classic/classic.exp @@ -50,9 +50,6 @@ ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory - ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:9: add_index ./examples/docs/optional_arguments/code_constructs/internal_app/internal_app_lib.mli:2: max @@ -199,8 +196,8 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#m -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -673,8 +670,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/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) +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... diff --git a/check/classic/classic.ref b/check/classic/classic.ref index 8b347601..397c8e31 100644 --- a/check/classic/classic.ref +++ b/check/classic/classic.ref @@ -50,9 +50,6 @@ ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory - ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:9: add_index ./examples/docs/optional_arguments/code_constructs/internal_app/internal_app_lib.mli:2: max @@ -199,8 +196,8 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#m: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused: Not detected ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -672,8 +669,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/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) +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... @@ -724,7 +720,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 596 -Success: 594 +Total: 593 +Success: 591 Failed: 2 -Ratio: 99.6644295302% +Ratio: 99.6627318718% diff --git a/check/internal/internal.exp b/check/internal/internal.exp index bc2224ab..7fd1065d 100644 --- a/check/internal/internal.exp +++ b/check/internal/internal.exp @@ -40,9 +40,6 @@ ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory - ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:9: add_index ./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused @@ -151,8 +148,8 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#m -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -625,8 +622,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/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) +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... diff --git a/check/internal/internal.ref b/check/internal/internal.ref index c7fe82d3..cb9c6458 100644 --- a/check/internal/internal.ref +++ b/check/internal/internal.ref @@ -40,9 +40,6 @@ ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory - ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:9: add_index ./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused @@ -151,8 +148,8 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#m: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused: Not detected ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -624,8 +621,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/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) +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... @@ -676,7 +672,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 552 -Success: 550 +Total: 549 +Success: 547 Failed: 2 -Ratio: 99.6376811594% +Ratio: 99.635701275% diff --git a/check/threshold-1/threshold-1.exp b/check/threshold-1/threshold-1.exp index 71a3e827..559fa7ac 100644 --- a/check/threshold-1/threshold-1.exp +++ b/check/threshold-1/threshold-1.exp @@ -40,9 +40,6 @@ ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory - ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:9: add_index ./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused @@ -203,6 +200,9 @@ ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_bin.ml:2: push_n_times +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory + ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:2: max ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:3: min @@ -442,8 +442,8 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#m -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -533,6 +533,10 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#pop ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#push +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used + ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used @@ -1090,8 +1094,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/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) +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... diff --git a/check/threshold-1/threshold-1.ref b/check/threshold-1/threshold-1.ref index 1808d140..11deb3e5 100644 --- a/check/threshold-1/threshold-1.ref +++ b/check/threshold-1/threshold-1.ref @@ -40,9 +40,6 @@ ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory - ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:9: add_index ./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused @@ -203,6 +200,9 @@ ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_bin.ml:2: push_n_times +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory + ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:2: max ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:3: min @@ -442,8 +442,8 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#m: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused: Not detected ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -532,6 +532,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#pop ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#push +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used: Not detected ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used @@ -1089,8 +1092,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/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) +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... @@ -1141,7 +1143,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 937 -Success: 935 -Failed: 2 -Ratio: 99.7865528282% +Total: 939 +Success: 934 +Failed: 5 +Ratio: 99.4675186368% 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 5a25dad4..57924286 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.exp +++ b/check/threshold-3-0.5/threshold-3-0.5.exp @@ -40,9 +40,6 @@ ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory - ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:9: add_index ./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused @@ -203,6 +200,9 @@ ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_bin.ml:2: push_n_times +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory + ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:2: max ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:3: min @@ -585,8 +585,8 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#m -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -676,6 +676,10 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#pop ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#push +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used + ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used @@ -1498,8 +1502,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/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) +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val 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 f44dd000..02db0a64 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.ref +++ b/check/threshold-3-0.5/threshold-3-0.5.ref @@ -40,9 +40,6 @@ ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory - ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:9: add_index ./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused @@ -203,6 +200,9 @@ ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_bin.ml:2: push_n_times +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory + ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:2: max ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:3: min @@ -585,8 +585,8 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#m: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused: Not detected ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -675,6 +675,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#pop ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#push +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used: Not detected ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used @@ -1493,8 +1496,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/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) +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... @@ -1545,7 +1547,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 1259 -Success: 1257 -Failed: 2 -Ratio: 99.8411437649% +Total: 1261 +Success: 1256 +Failed: 5 +Ratio: 99.6034892942% diff --git a/examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml b/examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml index 1c1961fa..a357939b 100644 --- a/examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml +++ b/examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml @@ -1,13 +1,31 @@ (* factoy_fun_indir.ml *) let factory_with_intermediate_binding () = let res = - object method unused_method = () end + object + method used_locally = () + method used = () + method unused = () + end in + res#used_locally; res let random_factory () = if Random.bool () then - object method m = () end - else - let res = object method m = () end in + object + method used = () + method unused = () + end + else begin + let res = + object + method used = () + method unused = () + end + in res + end + +let () = + (factory_with_intermediate_binding ()) # used; + (random_factory ()) # used From 25b6055f37361c2c0d36250b9ff485cbd52cb425 Mon Sep 17 00:00:00 2001 From: Corentin De Souza <9597216+fantazio@users.noreply.github.com> Date: Fri, 21 Aug 2026 18:27:05 +0200 Subject: [PATCH 2/3] [src][deadObj] fix factory_fun_indir In `add_var`, new expr constructs are now traversed to link the locally defined return value to the new value, and explore the branches on ifs, matches and tries. In `repr_exp`, `Texp_let` is not traversed. As a result, the FP/FN of the limitation are fixes. --- check/classic/classic.ref | 11 ++++--- check/internal/internal.ref | 11 ++++--- check/threshold-1/threshold-1.ref | 18 +++++----- check/threshold-3-0.5/threshold-3-0.5.ref | 18 +++++----- src/deadObj.ml | 40 +++++++++++++++++++++-- 5 files changed, 69 insertions(+), 29 deletions(-) diff --git a/check/classic/classic.ref b/check/classic/classic.ref index 397c8e31..650f501f 100644 --- a/check/classic/classic.ref +++ b/check/classic/classic.ref @@ -196,8 +196,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused + ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -721,6 +722,6 @@ Nothing else to report in this section Total: 593 -Success: 591 -Failed: 2 -Ratio: 99.6627318718% +Success: 593 +Failed: 0 +Ratio: 100.% diff --git a/check/internal/internal.ref b/check/internal/internal.ref index cb9c6458..e64ade50 100644 --- a/check/internal/internal.ref +++ b/check/internal/internal.ref @@ -148,8 +148,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused + ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -673,6 +674,6 @@ Nothing else to report in this section Total: 549 -Success: 547 -Failed: 2 -Ratio: 99.635701275% +Success: 549 +Failed: 0 +Ratio: 100.% diff --git a/check/threshold-1/threshold-1.ref b/check/threshold-1/threshold-1.ref index 11deb3e5..7040ff4b 100644 --- a/check/threshold-1/threshold-1.ref +++ b/check/threshold-1/threshold-1.ref @@ -442,8 +442,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused + ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -532,9 +533,10 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#pop ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#push -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used + ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used @@ -1144,6 +1146,6 @@ Nothing else to report in this section Total: 939 -Success: 934 -Failed: 5 -Ratio: 99.4675186368% +Success: 939 +Failed: 0 +Ratio: 100.% 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 02db0a64..673e6ea3 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.ref +++ b/check/threshold-3-0.5/threshold-3-0.5.ref @@ -585,8 +585,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused + ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -675,9 +676,10 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#pop ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#push -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used: Not detected +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally +./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used + ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used @@ -1548,6 +1550,6 @@ Nothing else to report in this section Total: 1261 -Success: 1256 -Failed: 5 -Ratio: 99.6034892942% +Success: 1261 +Failed: 0 +Ratio: 100.% diff --git a/src/deadObj.ml b/src/deadObj.ml index c3a44832..d4f70e84 100644 --- a/src/deadObj.ml +++ b/src/deadObj.ml @@ -147,6 +147,7 @@ let rec repr_exp expr f = | Texp_sequence (_, expr) | Texp_function (_, Tfunction_cases { cases = {c_rhs=expr; _}::_ ; _ }) | Texp_function (_, Tfunction_body expr) + | Texp_let (_, _, expr) | Texp_apply (expr, _) -> repr_exp expr f | _ -> f expr @@ -262,16 +263,49 @@ let tstr ({ci_expr; ci_decl = {cty_loc = loc; _}; ci_id_name = {txt = name; _}; let add_var loc expr = - let kind expr = + let rec kind expr = + let find_first_kind exprs = + (* For alternative results: find the first non-`Ignore kind *) + List.find_map + (fun expr -> + match repr_exp expr kind with + | `Ignore -> None + | res -> Some res + ) + exprs + |> Option.value ~default:`Ignore + in + let find_first_case_kind cases = + List.map (fun {c_rhs; _} -> c_rhs) cases + |> find_first_kind + in match expr.exp_desc with - | Texp_object _ -> `Obj - | Texp_new (_, _, {cty_loc = {Location.loc_start = cty_loc; _}; _}) -> `New cty_loc + (* Result identified *) + | Texp_object _ -> + `Obj + | Texp_new (_, _, {cty_loc = {Location.loc_start = cty_loc; _}; _}) -> + `New cty_loc + | Texp_ident (_, _, {Types.val_loc; _}) -> + `Ident val_loc.Location.loc_start + (* Cases not traversed by repr_exp *) + | Texp_match (_, cases, _, _) -> + find_first_case_kind cases + | Texp_try (_, cases, _) -> + find_first_case_kind cases + | Texp_ifthenelse (_, then_, Some else_) -> + find_first_kind [then_; else_] + (* Default *) | _ -> `Ignore in match repr_exp expr kind with | `Obj -> last_class := loc; | `New cty_loc -> add_equal loc cty_loc + | `Ident id_loc -> + let expr_loc : Location.t = expr.exp_loc in + if id_loc >= expr_loc.loc_start && id_loc <= expr_loc.loc_end then + (* ident is defined within expr *) + add_equal id_loc loc | `Ignore -> () From 7860ebb36ac27fa0d3b7b95e70f6242390c1707c Mon Sep 17 00:00:00 2001 From: Corentin De Souza <9597216+fantazio@users.noreply.github.com> Date: Fri, 21 Aug 2026 19:04:25 +0200 Subject: [PATCH 3/3] [docs][methods] move factory_fun_indir to code_constructs It is referenced by the factory function documentation, and not a limitation anymore. The tests have been moved accordingly. --- check/classic/classic.exp | 8 +- check/classic/classic.ref | 8 +- check/internal/internal.exp | 8 +- check/internal/internal.ref | 8 +- check/threshold-1/threshold-1.exp | 22 +++--- check/threshold-1/threshold-1.ref | 22 +++--- check/threshold-3-0.5/threshold-3-0.5.exp | 22 +++--- check/threshold-3-0.5/threshold-3-0.5.ref | 22 +++--- docs/methods/METHODS.md | 77 ------------------- docs/methods/code_constructs/FACTORY_FUN.md | 21 ++--- .../docs/methods/code_constructs/Makefile | 2 + .../factory_fun_indir/Makefile | 0 .../factory_fun_indir/factory_fun_indir.ml | 0 examples/docs/methods/limitations/Makefile | 4 +- 14 files changed, 70 insertions(+), 154 deletions(-) rename examples/docs/methods/{limitations => code_constructs}/factory_fun_indir/Makefile (100%) rename examples/docs/methods/{limitations => code_constructs}/factory_fun_indir/factory_fun_indir.ml (100%) diff --git a/check/classic/classic.exp b/check/classic/classic.exp index 9b63431c..c7d1a0aa 100644 --- a/check/classic/classic.exp +++ b/check/classic/classic.exp @@ -189,6 +189,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory#unused_method ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#reset +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj#unused_method ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#reset @@ -196,9 +199,6 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused - ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -670,7 +670,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/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... diff --git a/check/classic/classic.ref b/check/classic/classic.ref index 650f501f..cea2bcfe 100644 --- a/check/classic/classic.ref +++ b/check/classic/classic.ref @@ -189,6 +189,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory#unused_method ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#reset +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj#unused_method ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#reset @@ -196,9 +199,6 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused - ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -670,7 +670,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/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... diff --git a/check/internal/internal.exp b/check/internal/internal.exp index 7fd1065d..84a6c92a 100644 --- a/check/internal/internal.exp +++ b/check/internal/internal.exp @@ -141,6 +141,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory#unused_method ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#reset +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj#unused_method ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#reset @@ -148,9 +151,6 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused - ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -622,7 +622,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/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... diff --git a/check/internal/internal.ref b/check/internal/internal.ref index e64ade50..a004e70d 100644 --- a/check/internal/internal.ref +++ b/check/internal/internal.ref @@ -141,6 +141,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory#unused_method ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#reset +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj#unused_method ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#reset @@ -148,9 +151,6 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused - ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -622,7 +622,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/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... diff --git a/check/threshold-1/threshold-1.exp b/check/threshold-1/threshold-1.exp index 559fa7ac..be1548ac 100644 --- a/check/threshold-1/threshold-1.exp +++ b/check/threshold-1/threshold-1.exp @@ -194,15 +194,15 @@ ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:4: push_n_times +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:4: push_n_times ./examples/docs/methods/code_constructs/object_type/object_type_bin.ml:4: push_n_times ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_bin.ml:2: push_n_times -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory - ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:2: max ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:3: min @@ -435,6 +435,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory#unused_method ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#reset +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj#unused_method ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#reset @@ -442,9 +445,6 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused - ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -522,6 +522,10 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#pop ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#push +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#peek ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#pop ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#push @@ -533,10 +537,6 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#pop ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#push -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used - ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used @@ -1094,7 +1094,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/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... diff --git a/check/threshold-1/threshold-1.ref b/check/threshold-1/threshold-1.ref index 7040ff4b..aed84db1 100644 --- a/check/threshold-1/threshold-1.ref +++ b/check/threshold-1/threshold-1.ref @@ -194,15 +194,15 @@ ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:4: push_n_times +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:4: push_n_times ./examples/docs/methods/code_constructs/object_type/object_type_bin.ml:4: push_n_times ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_bin.ml:2: push_n_times -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory - ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:2: max ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:3: min @@ -435,6 +435,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory#unused_method ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#reset +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj#unused_method ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#reset @@ -442,9 +445,6 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused - ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -522,6 +522,10 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#pop ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#push +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#peek ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#pop ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#push @@ -533,10 +537,6 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#pop ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#push -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used - ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used @@ -1094,7 +1094,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/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... 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 57924286..313bc7ea 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.exp +++ b/check/threshold-3-0.5/threshold-3-0.5.exp @@ -194,15 +194,15 @@ ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:4: push_n_times +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:4: push_n_times ./examples/docs/methods/code_constructs/object_type/object_type_bin.ml:4: push_n_times ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_bin.ml:2: push_n_times -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory - ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:2: max ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:3: min @@ -578,6 +578,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory#unused_method ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#reset +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj#unused_method ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#reset @@ -585,9 +588,6 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused - ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -665,6 +665,10 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#pop ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#push +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#peek ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#pop ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#push @@ -676,10 +680,6 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#pop ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#push -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used - ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used @@ -1502,7 +1502,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/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val 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 673e6ea3..7fed8c11 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.ref +++ b/check/threshold-3-0.5/threshold-3-0.5.ref @@ -194,15 +194,15 @@ ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:4: push_n_times +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:4: push_n_times ./examples/docs/methods/code_constructs/object_type/object_type_bin.ml:4: push_n_times ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_bin.ml:2: push_n_times -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory - ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:2: max ./examples/docs/optional_arguments/code_constructs/external_app/external_app_lib.mli:3: min @@ -578,6 +578,9 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/factory_fun/factory_fun_bin.ml:2: unused_factory#unused_method ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#reset +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_bin.ml:2: unused_obj#unused_method ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#reset @@ -585,9 +588,6 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#reset -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#unused -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#unused - ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -665,6 +665,10 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#pop ./examples/docs/methods/code_constructs/factory_fun/factory_fun_lib.mli:2: get_stack#push +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used + ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#peek ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#pop ./examples/docs/methods/code_constructs/immediate_object/immediate_object_lib.mli:2: int_stack#push @@ -676,10 +680,6 @@ Nothing else to report in this section ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#pop ./examples/docs/methods/code_constructs/polymorphic_class/polymorphic_class_lib.mli:2: stack#push -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:2: factory_with_intermediate_binding#used_locally -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:13: random_factory#used - ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used @@ -1498,7 +1498,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/methods/limitations/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) +./examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml:20: let x = ... in x (=> useless binding) ./examples/docs/optional_arguments/code_constructs/hof/hof_bin.ml:2: val f: ... -> (... -> ?_:_ -> ...) -> ... diff --git a/docs/methods/METHODS.md b/docs/methods/METHODS.md index dedd4926..b37761f4 100644 --- a/docs/methods/METHODS.md +++ b/docs/methods/METHODS.md @@ -9,7 +9,6 @@ + [Limitations](#limitations) + [Class type](#class-type) + [Object type](#object-type) - + [Factory function](#factory-function) # Methods @@ -251,79 +250,3 @@ make: Leaving directory '/tmp/docs/methods/limitations/alias' The analyzer reports `original#used_by_alias` although it is used by `alias#used_by_alias`. - -## Factory function - -Related issue : -[issue #67](https://github.com/LexiFi/dead_code_analyzer/issues/67). - -Factory functions' methods analysis is currently very limited to situations like -the one in the [Factory function](./code_constructs/FACTORY_FUN.md) example : -functions without intermediate binding to the returned object and without -alternative return values. I.e. if the returned object is in an if-expressions -or bound to a name, then the analyzer fails to track its methods. -This leads to **false negatives**. - -### Example - -The reference files for this example are in the -[factory\_fun\_indir](../../examples/docs/methods/limitations/factory_fun_indir) directory. - -The reference takes place in `/tmp/docs/methods/limitations`, which -is a copy of the [limitations](../../../examples/docs/methods/limitations) -directory. Reported locations may differ depending on the location of the source -files. - -The compilation command is : -``` -make -C factory_fun_indir build -``` - -The analysis command is : -``` -make -C factory_fun_indir analyze -``` - -The compile + analyze command is : -``` -make -C factory_fun_indir -``` - -Code: -```OCaml -(* factoy_fun_indir.ml *) -let factory_with_intermediate_binding () = - let res = - object method m = () end - in - res - -let random_factory () = - if Random.bool () then - object method m = () end - else - let res = object method m = () end in - res -``` - -Compile and analyze: -``` -$ make -C factory_fun_indir -make: Entering directory '/tmp/docs/methods/limitations/factory_fun_indir' -ocamlopt -bin-annot factory_fun_indir.ml -dead_code_analyzer --nothing -M all . -Scanning files... - [DONE] - -.> UNUSED METHODS: -================= - -Nothing else to report in this section --------------------------------------------------------------------------------- - - -make: Leaving directory '/tmp/docs/methods/limitations/factory_fun_indir' -``` - -The analyzer does not report `random_factory#m` nor -`factory_with_intermediate_binding#m`. diff --git a/docs/methods/code_constructs/FACTORY_FUN.md b/docs/methods/code_constructs/FACTORY_FUN.md index 76ad092e..99a021e6 100644 --- a/docs/methods/code_constructs/FACTORY_FUN.md +++ b/docs/methods/code_constructs/FACTORY_FUN.md @@ -21,20 +21,6 @@ The compile + analyze command is : make -C factory_fun ``` -> [!IMPORTANT] -> **LIMITATION** -> -> Only factory functions that return the object without intermediate binding -> in at least one branch are understood by the analyzer. This may lead to -> **false negatives**. -> See [Factory function | Limitations](../METHODS.md#factory-function). -> -> Storing the result of a factory function in a new binding breaks the analysis. -> Although 2 calls to the same factory function may produce different objects, -> they are considered to be the same by the analyzer. Hence, storing the result -> in a new binding is similar to an alias, which may lead to **false positives**. -> See [Alias | Limitations](../METHODS.md#alias) - ## First run Code: @@ -126,3 +112,10 @@ functions, making the functions behave similarly to class constructors. The reported methods can be removed from the `.mli` and `.ml`. Our work here is done. + +## Complex factory functions + +An example where the factory function may return different values or +manipulate the return value is available in the +[factory_fun_indir](../../../examples/docs/methods/code_constructs/factory_fun_indir) +directory. diff --git a/examples/docs/methods/code_constructs/Makefile b/examples/docs/methods/code_constructs/Makefile index 4411c077..ba1a1da8 100644 --- a/examples/docs/methods/code_constructs/Makefile +++ b/examples/docs/methods/code_constructs/Makefile @@ -10,6 +10,7 @@ build: make -C inheritance build make -C immediate_object build make -C factory_fun build + make -C factory_fun_indir build make -C object_type build make -C coercion build make -C alias build @@ -23,6 +24,7 @@ clean: make -C inheritance clean make -C immediate_object clean make -C factory_fun clean + make -C factory_fun_indir clean make -C object_type clean make -C coercion clean make -C alias clean diff --git a/examples/docs/methods/limitations/factory_fun_indir/Makefile b/examples/docs/methods/code_constructs/factory_fun_indir/Makefile similarity index 100% rename from examples/docs/methods/limitations/factory_fun_indir/Makefile rename to examples/docs/methods/code_constructs/factory_fun_indir/Makefile diff --git a/examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml b/examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml similarity index 100% rename from examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml rename to examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml diff --git a/examples/docs/methods/limitations/Makefile b/examples/docs/methods/limitations/Makefile index 82966a2b..574f0211 100644 --- a/examples/docs/methods/limitations/Makefile +++ b/examples/docs/methods/limitations/Makefile @@ -2,10 +2,8 @@ all: build -build: - make -C factory_fun_indir build +build: ; clean: rm -f *~ *.cm* *.o *.obj - make -C factory_fun_indir clean