Skip to content

Commit 13613a9

Browse files
committed
[docs][exported_values] add issue LexiFi#55 to limitations
1 parent 97cd19c commit 13613a9

File tree

8 files changed

+114
-13
lines changed

8 files changed

+114
-13
lines changed

check/classic/classic.ref

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
./examples/docs/exported_values/hello_world/hello_world_with_intf.mli:3: goodbye
2626
./examples/docs/exported_values/hello_world/hello_world_with_intf.mli:4: world
2727

28+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:20: copy: Should not be detected
29+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:25: id: Should not be detected
30+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:40: new_method: Should not be detected
31+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:41: public_method_label: Should not be detected
2832
./examples/docs/exported_values/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected
2933
./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused
3034
./examples/using_dune/preprocessed_lib/preprocessed.mli:3: internally_used
@@ -619,7 +623,7 @@ Nothing else to report in this section
619623
--------------------------------------------------------------------------------
620624

621625

622-
Total: 532
626+
Total: 536
623627
Success: 531
624-
Failed: 1
625-
Ratio: 99.8120300752%
628+
Failed: 5
629+
Ratio: 99.0671641791%

check/internal/internal.ref

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
./examples/docs/exported_values/code_constructs/module/module_lib.mli:6: M.unused
1717

18+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:20: copy: Should not be detected
19+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:25: id: Should not be detected
20+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:40: new_method: Should not be detected
21+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:41: public_method_label: Should not be detected
1822
./examples/docs/exported_values/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected
1923
./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused
2024
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:2: unused
@@ -574,7 +578,7 @@ Nothing else to report in this section
574578
--------------------------------------------------------------------------------
575579

576580

577-
Total: 490
581+
Total: 494
578582
Success: 489
579-
Failed: 1
580-
Ratio: 99.7959183673%
583+
Failed: 5
584+
Ratio: 98.987854251%

check/threshold-1/threshold-1.ref

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
./examples/docs/exported_values/code_constructs/module/module_lib.mli:6: M.unused
1717

18+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:20: copy: Should not be detected
19+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:25: id: Should not be detected
20+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:40: new_method: Should not be detected
21+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:41: public_method_label: Should not be detected
1822
./examples/docs/exported_values/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected
1923
./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused
2024
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:2: unused
@@ -951,7 +955,7 @@ Nothing else to report in this section
951955
--------------------------------------------------------------------------------
952956

953957

954-
Total: 821
958+
Total: 825
955959
Success: 820
956-
Failed: 1
957-
Ratio: 99.8781973203%
960+
Failed: 5
961+
Ratio: 99.3939393939%

check/threshold-3-0.5/threshold-3-0.5.ref

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
./examples/docs/exported_values/code_constructs/module/module_lib.mli:6: M.unused
1717

18+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:20: copy: Should not be detected
19+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:25: id: Should not be detected
20+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:40: new_method: Should not be detected
21+
./examples/docs/exported_values/limitations/incl_same_name/oo.mli:41: public_method_label: Should not be detected
1822
./examples/docs/exported_values/limitations/sigincl/sigincl_lib.mli:10: I.x: Should not be detected
1923
./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused
2024
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:2: unused
@@ -1340,7 +1344,7 @@ Nothing else to report in this section
13401344
--------------------------------------------------------------------------------
13411345

13421346

1343-
Total: 1133
1347+
Total: 1137
13441348
Success: 1132
1345-
Failed: 1
1346-
Ratio: 99.9117387467%
1349+
Failed: 5
1350+
Ratio: 99.5602462621%

docs/exported_values/EXPORTED_VALUES.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
+ [Limitations](#limitations)
1212
+ [Module type](#module-type)
1313
+ [Include module type with substitution](#include-module-type-with-substitution)
14+
+ [Including a module with same name](#including-a-module-with-the-same-name)
1415

1516
# Exported Values
1617

@@ -318,3 +319,72 @@ make: Leaving directory '/tmp/docs/exported_values/limitations/sigincl'
318319

319320
The analyzer reports `I.x` at the line where `T` is included although it is
320321
actually declared in `T`.
322+
323+
## Including a module with the same name
324+
325+
Related issue :
326+
[issue #55](https://github.com/LexiFi/dead_code_analyzer/issues/55).
327+
328+
According to the semantics described in the
329+
[Include](./code_constructs/INCLUDE.md) example, values re-exported via included
330+
should not be reported. However, it may happen that values re-exported by
331+
including a compilation unit out of the current codebase are reported when the
332+
re-exporting compilation unit has the same name as the one included.
333+
334+
### Example
335+
336+
The reference files for this example are in the
337+
[incl\_same\_name](../examples/docs/exported_values/limitations/incl_same_name)
338+
directory.
339+
340+
The reference takes place in `/tmp/docs/exported_values/limitations`, which
341+
is a copy of the [limitations](../examples/docs/exported_values/limitations)
342+
directory. Reported locations may differ depending on the location of the source
343+
files.
344+
345+
The compilation command is :
346+
```
347+
make -C incl_same_name build
348+
```
349+
350+
The analysis command is :
351+
```
352+
make -C incl_same_name analyze
353+
```
354+
355+
The compile + analyze command is :
356+
```
357+
make -C incl_same_name
358+
```
359+
360+
Code:
361+
```OCaml
362+
(* oo.ml *)
363+
include Stdlib.Oo
364+
```
365+
366+
Compile and analyze:
367+
```
368+
$ make -C incl_same_name
369+
make: Entering directory '/tmp/docs/exported_values/limitations/incl_same_name'
370+
ocamlopt -bin-annot oo.ml
371+
dead_code_analyzer --nothing -E all .
372+
Scanning files...
373+
[DONE]
374+
375+
.> UNUSED EXPORTED VALUES:
376+
=========================
377+
/tmp/docs/exported_values/limitations/incl_same_name/oo.mli:20: copy
378+
/tmp/docs/exported_values/limitations/incl_same_name/oo.mli:25: id
379+
/tmp/docs/exported_values/limitations/incl_same_name/oo.mli:40: new_method
380+
/tmp/docs/exported_values/limitations/incl_same_name/oo.mli:41: public_method_label
381+
382+
Nothing else to report in this section
383+
--------------------------------------------------------------------------------
384+
385+
386+
make: Leaving directory '/tmp/docs/exported_values/limitations/incl_same_name'
387+
```
388+
389+
The analyzer reports values in `oo.mli` although they are included from
390+
`Stdlib.Oo`.

examples/docs/exported_values/limitations/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ all: build
44

55
build:
66
make -C sigincl build
7+
make -C incl_same_name build
78

89
clean:
910
rm -f *~ *.cm* *.o *.obj
1011
make -C sigincl clean
11-
12+
make -C incl_same_name clean
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
SRC:=oo.ml
2+
3+
all: build analyze
4+
5+
build:
6+
ocamlopt -bin-annot ${SRC}
7+
8+
analyze:
9+
dead_code_analyzer --nothing -E all .
10+
11+
clean:
12+
rm -f *.cm* *.o a.out
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(* oo.ml *)
2+
include Stdlib.Oo

0 commit comments

Comments
 (0)