Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007684OCamlmiscpublic2017-12-01 21:372017-12-27 16:02
ReporterIguernlala 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version4.06.0 
Target VersionFixed in Version 
Summary0007684: When warning 60 is activated, a used module is reported as "unused"
DescriptionThis happens with mutually recursive modules as shown in the example below. Module X1 is used in module M, and module M is exported in the interface. But, if warning 60 is set, an "unused module X1" warning is triggered when compiling as follows:

$ ocamlc -c -w +60 foo.mli foo.ml

File "foo.ml", line 8, characters 0-43:
Warning 60: unused module X1.

(* content of foo.ml *)
module type S = sig
  type t
end

module rec M : S = struct
  type t = X1 of X1.t
end
and X1 : S = struct
  type t = M.t list
end


(* content of foo.mli *)
module type S = sig
  type t
end

module M : S
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0018729)
gasche (administrator)
2017-12-01 22:06

Reproduced under 4.06.0.
(0018730)
Iguernlala (reporter)
2017-12-05 07:08
edited on: 2017-12-07 09:14

I forgot to say that trying to disable this warning with an annotation `[@@@ocaml.warning "-60"]` did not work

[Edited]
Actually, I manage to disable the warning if I put the annotation before 'module rec M ...'. (I had tried to put the annotation before 'and module X1 ...' previously)

(0018789)
shinwell (developer)
2017-12-27 13:39

Here is another, probably related, example which I came across this week.

w60.ml
======

module type S = sig val f : unit -> unit end

module F (X : S) = struct let f () = X.f () end

module rec A : S =
  F (struct let f () = B.f () end)
and B : S =
  F (struct let f () = failwith "ok" end)

let f = A.f

let () = f ()

w60.mli
=======

val f : unit -> unit

Using a recent trunk:

$ ocamlc w60.mli
$ ocamlc -w +60 -o w60 w60.ml
File "w60.ml", line 7, characters 0-42:
Warning 60: unused module B.
$ ./w60
Fatal error: exception Failure("ok")

The warning is bogus, as evidenced by the exception, which shows that [B] was used.

The bogus warning does not appear if the .mli file is absent.
(0018790)
shinwell (developer)
2017-12-27 16:02

As an aside: the following version produces a runtime exception:

  Fatal error: exception Undefined_recursive_module("w60.ml", 23, 2)

This surprised me at first, but it appears to be related to Mantis 2629. It would indeed be nice if there were a compile-time check for this as suggested in that issue:

module type S = sig val f : unit -> unit end

module F (X : S) = struct let f = X.f end

module rec A : S =
  F (struct let f = B.f end)
and B : S =
  F (struct let f () = failwith "ok" end)

let f = A.f

let () = f ()

- Issue History
Date Modified Username Field Change
2017-12-01 21:37 Iguernlala New Issue
2017-12-01 22:06 gasche Note Added: 0018729
2017-12-01 22:06 gasche Status new => acknowledged
2017-12-05 07:08 Iguernlala Note Added: 0018730
2017-12-07 09:14 Iguernlala Note Edited: 0018730 View Revisions
2017-12-27 13:39 shinwell Note Added: 0018789
2017-12-27 13:46 shinwell Summary When warning 60 is activated, a used module is reported as "unsued" => When warning 60 is activated, a used module is reported as "unused"
2017-12-27 13:46 shinwell Priority low => normal
2017-12-27 16:02 shinwell Note Added: 0018790


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker