diff --git a/check/classic/classic.exp b/check/classic/classic.exp index 6ed8bc5b..c7d1a0aa 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 @@ -192,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 @@ -199,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#m -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m - ./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/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 8b347601..cea2bcfe 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 @@ -192,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 @@ -199,8 +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#m: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m: 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 +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/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: ... -> (... -> ?_:_ -> ...) -> ... @@ -724,7 +721,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 596 -Success: 594 -Failed: 2 -Ratio: 99.6644295302% +Total: 593 +Success: 593 +Failed: 0 +Ratio: 100.% diff --git a/check/internal/internal.exp b/check/internal/internal.exp index bc2224ab..84a6c92a 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 @@ -144,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 @@ -151,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#m -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m - ./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/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 c7fe82d3..a004e70d 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 @@ -144,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 @@ -151,8 +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#m: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m: 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 +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/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: ... -> (... -> ?_:_ -> ...) -> ... @@ -676,7 +673,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 552 -Success: 550 -Failed: 2 -Ratio: 99.6376811594% +Total: 549 +Success: 549 +Failed: 0 +Ratio: 100.% diff --git a/check/threshold-1/threshold-1.exp b/check/threshold-1/threshold-1.exp index 71a3e827..be1548ac 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 @@ -197,6 +194,9 @@ ./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 @@ -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#m -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m - ./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 @@ -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/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 1808d140..aed84db1 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 @@ -197,6 +194,9 @@ ./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 @@ -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,8 +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#m: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m: Not detected ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -521,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 @@ -1089,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/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: ... -> (... -> ?_:_ -> ...) -> ... @@ -1141,7 +1145,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 937 -Success: 935 -Failed: 2 -Ratio: 99.7865528282% +Total: 939 +Success: 939 +Failed: 0 +Ratio: 100.% 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..313bc7ea 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 @@ -197,6 +194,9 @@ ./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 @@ -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#m -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m - ./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 @@ -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/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 f44dd000..7fed8c11 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 @@ -197,6 +194,9 @@ ./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 @@ -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,8 +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#m: Not detected -./examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml:8: random_factory#m: Not detected ./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused ./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused @@ -664,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 @@ -1493,8 +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: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/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: ... -> (... -> ?_:_ -> ...) -> ... @@ -1545,7 +1549,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 1259 -Success: 1257 -Failed: 2 -Ratio: 99.8411437649% +Total: 1261 +Success: 1261 +Failed: 0 +Ratio: 100.% 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/code_constructs/factory_fun_indir/factory_fun_indir.ml b/examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml new file mode 100644 index 00000000..a357939b --- /dev/null +++ b/examples/docs/methods/code_constructs/factory_fun_indir/factory_fun_indir.ml @@ -0,0 +1,31 @@ +(* factoy_fun_indir.ml *) +let factory_with_intermediate_binding () = + let res = + object + method used_locally = () + method used = () + method unused = () + end + in + res#used_locally; + res + +let random_factory () = + if Random.bool () then + 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 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 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 deleted file mode 100644 index 1c1961fa..00000000 --- a/examples/docs/methods/limitations/factory_fun_indir/factory_fun_indir.ml +++ /dev/null @@ -1,13 +0,0 @@ -(* factoy_fun_indir.ml *) -let factory_with_intermediate_binding () = - let res = - object method unused_method = () end - in - res - -let random_factory () = - if Random.bool () then - object method m = () end - else - let res = object method m = () end in - res 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 -> ()