Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007314OCamltypingpublic2016-08-02 14:412017-04-27 21:45
Reporterbobot 
Assigned Tofrisch 
PrioritynormalSeverityblockReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target Version4.04.0 +dev / +beta1 / +beta2Fixed in Version4.04.0 +dev / +beta1 / +beta2 
Summary0007314: In 4.04 branch the unused module warning is unsound
DescriptionOn the following code and interface:


```
module type Comparable = sig
  val id: int
end

module Make_graph (P:sig module Id:Comparable end) = struct
  let foo = P.Id.id
end

module Fold_ordered(P: sig module Id:Comparable end) =
struct
  include Make_graph(struct module Id = P.Id end)
end
```

```
module type Comparable = sig
  val id: int
end

module Fold_ordered(P: sig module Id:Comparable end): sig
  val foo: int
end

```

with the warning 60 activated and branch 4.04 reports:
```
File "test3.ml", line 9, characters 27-47:
Warning 60: unused module Id.
```

(line 9 is: `module Fold_ordered(P: sig module Id:Comparable end) =`)
Steps To Reproduceboot/ocamlrun ./ocamlc -nostdlib -I stdlib -I byterun/ -w +A -o test3.cmi test3.mli
boot/ocamlrun ./ocamlc -nostdlib -I stdlib -I byterun/ -w +A -o test3 test3.ml
Additional InformationThe functors and the interface are needed
TagsNo tags attached.
Attached Files

- Relationships
parent of 0007522acknowledged Spurious unused module warning (warning 60) with recursive modules 
Not all the children of this issue are yet resolved or closed.

-  Notes
(0016168)
bobot (reporter)
2016-08-02 15:02

Severity "block" is a little too much, the warning is not enabled by default, so we could not activate it for Frama-c.
(0016187)
lpw25 (developer)
2016-08-05 13:49
edited on: 2016-08-05 13:49

Even simpler example:

  module M = struct
    module N = struct end
  end

  module O = M.N

with interface:

  module M : sig end

  module O : sig end

gives:

  File "bug.ml", line 2, characters 2-23:
  Warning 60: unused module N.

(0016209)
bobot (reporter)
2016-08-18 16:37

Could someone tag it with target version = 4.04? Thanks.
(0016211)
gasche (developer)
2016-08-18 17:20

Of course, thanks for the ping.
(0016226)
frisch (developer)
2016-08-23 09:56

This is a missing call to mark_module_used in the Ldot case of Env.lookup_module. Will fix soon.
(0016227)
frisch (developer)
2016-08-23 10:57
edited on: 2016-08-23 11:00

Fixed on trunk in commit 772b92a27a18e92dbcf7016cc80ea8575f74c81c, non-regression test added in commit e49f656d301792b67a230bc32d0c065febdc1098. Fix (but not the test) cherry-picked to 4.04 in commit 9598de3e4a36fd53f1b7fedf3c091134aee4fdbc.

(0016230)
bobot (reporter)
2016-08-23 15:12

@frisch Great thank you. Now we detect many many really unused module! Do you have a tip for suppressing the warning when a module is defined only for the side effect of the function application?

module Empty = Register(...)
(0016231)
lpw25 (developer)
2016-08-23 15:45

I have a patch to allow:

  module _ = ...

for that case:

  https://github.com/lpw25/ocaml/tree/underscore_module [^]

but it still needs a little bit of work (and rebasing up to trunk).
(0016232)
bobot (reporter)
2016-08-23 16:13

@lpw25 cool!! (perhaps `module () = ...` could be also useful for empty module).

@frisch There is another warning 60 unsoundness with recursive module, but I'm not able to reduce the problem. At [1]:

File "src/libraries/datatype/datatype.ml", line 775, characters 0-287:
Warning 60: unused module Pair_name.


If you have an idea without a reduced problem that would be great, otherwise I would try again to reduce it and open a proper bug.

[1]: https://github.com/Frama-C/Frama-C-snapshot/blob/master/src/libraries/datatype/datatype.ml#L775 [^]
(0016233)
frisch (developer)
2016-08-23 16:20

> Do you have a tip for suppressing the warning when a module is defined only for the side effect of the function application?

include (... : sig end)

> If you have an idea without a reduced problem that would be great, otherwise I would try again to reduce it and open a proper bug.

That would be very useful. I don't have an idea, upfront.
(0016315)
eponier (reporter)
2016-09-21 10:40

The warning seems to appear as soon as you have recursive modules and they are not all declared in the signature. The excluded ones are reported as being useless.

Simple contrived example:

module M : sig module A : sig type t end end =
struct
  module rec A : sig type t end = struct type t = B.t end
  and B : sig type t end = struct type t = A.t list end
end

With 4.04.0+beta2, "ocamlc -w A" returns "Warning 60 : unused module B".

- Issue History
Date Modified Username Field Change
2016-08-02 14:41 bobot New Issue
2016-08-02 15:02 bobot Note Added: 0016168
2016-08-05 13:49 lpw25 Note Added: 0016187
2016-08-05 13:49 lpw25 Note Edited: 0016187 View Revisions
2016-08-18 16:37 bobot Note Added: 0016209
2016-08-18 17:20 gasche Target Version => 4.04.0 +dev / +beta1 / +beta2
2016-08-18 17:20 gasche Note Added: 0016211
2016-08-23 09:56 frisch Note Added: 0016226
2016-08-23 10:57 frisch Note Added: 0016227
2016-08-23 11:00 frisch Note Edited: 0016227 View Revisions
2016-08-23 11:00 frisch Assigned To => frisch
2016-08-23 11:00 frisch Status new => assigned
2016-08-23 11:00 frisch Status assigned => resolved
2016-08-23 11:00 frisch Fixed in Version => 4.04.0 +dev / +beta1 / +beta2
2016-08-23 11:00 frisch Resolution open => fixed
2016-08-23 15:12 bobot Note Added: 0016230
2016-08-23 15:45 lpw25 Note Added: 0016231
2016-08-23 16:13 bobot Note Added: 0016232
2016-08-23 16:20 frisch Note Added: 0016233
2016-09-21 10:40 eponier Note Added: 0016315
2017-02-23 16:45 doligez Category OCaml typing => typing
2017-04-27 21:45 dra Relationship added parent of 0007522


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker