Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007701OCamltypingpublic2017-12-29 19:372018-05-05 16:00
Reporterantron 
Assigned Tolpw25 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.06.0 
Target VersionFixed in Version4.07.0+dev/beta2/rc1/rc2 
Summary0007701: Doc comment dropped from empty .mli file
DescriptionWhen an .mli file consists of only a (** ... *) comment, the comment does not appear in the signature item list of the signature read from the corresponding .cmti file. By contrast, if the signature includes a comment and some other items, the comment appears in the signature item list.
Steps To Reproduceempty.mli:

(** This comment will be lost by the compiler. *)


nonempty.mli:

(** This comment will be kept by the compiler. *)

val foo : unit


count_sig_items.ml:

let () =
  let file = Sys.argv.(1) in
  let cmt = Cmt_format.read_cmt file in
  match cmt.cmt_annots with
  | Interface signature ->
    signature.Typedtree.sig_items
    |> List.length
    |> string_of_int
    |> print_endline
  | _ ->
    assert false


Makefile:

.PHONY : reproduce
reproduce :
    ocamlc -version
    ocamlc -bin-annot -o empty.cmi -c empty.mli
    ocamlc -bin-annot -o nonempty.cmi -c nonempty.mli
    ocamlfind opt -linkpkg -package compiler-libs.common count_sig_items.ml
    ./a.out empty.cmti
    ./a.out nonempty.cmti

.PHONY : clean
clean :
    rm -f *.cmi *.cmti *.cmx *.o a.out


Running this (make), the output is:

ocamlc -version
4.06.0
ocamlc -bin-annot -o empty.cmi -c empty.mli
ocamlc -bin-annot -o nonempty.cmi -c nonempty.mli
ocamlfind opt -linkpkg -package compiler-libs.common count_sig_items.ml
./a.out empty.cmti
0
./a.out nonempty.cmti
2


I would expect the output to be 1, 2.
TagsNo tags attached.
Attached Files

- Relationships
duplicate of 0007138resolvedlpw25 Warning 50 triggers on "empty" files 

-  Notes
(0018817)
octachron (developer)
2018-01-06 12:00

A quick workaround for this issue is to add two empty new lines before the documentation comment.

For a more robust fix, see https://github.com/ocaml/ocaml/pull/1562 [^] .
(0019102)
gasche (administrator)
2018-05-05 16:00

After another iteration, a fix was merged from

  https://github.com/ocaml/ocaml/pull/1693 [^]

which I am currently working on backporting into 4.07.

- Issue History
Date Modified Username Field Change
2017-12-29 19:37 antron New Issue
2018-01-06 12:00 octachron Note Added: 0018817
2018-01-06 12:00 octachron Assigned To => octachron
2018-01-06 12:00 octachron Status new => assigned
2018-01-09 16:51 trefis Relationship added duplicate of 0007138
2018-05-05 16:00 gasche Note Added: 0019102
2018-05-05 16:00 gasche Status assigned => resolved
2018-05-05 16:00 gasche Fixed in Version => 4.07.0+dev/beta2/rc1/rc2
2018-05-05 16:00 gasche Resolution open => fixed
2018-05-05 16:00 gasche Assigned To octachron => lpw25


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker