Original bug ID: 7701 Reporter: antron Assigned to:@lpw25 Status: resolved (set by @gasche on 2018-05-05T14:00:49Z) Resolution: fixed Priority: normal Severity: minor Version: 4.06.0 Fixed in version: 4.07.0+dev/beta2/rc1/rc2 Category: typing Duplicate of:#7138 Monitored by:@gasche
Bug description
When 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 reproduce
empty.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
Original bug ID: 7701
Reporter: antron
Assigned to: @lpw25
Status: resolved (set by @gasche on 2018-05-05T14:00:49Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.06.0
Fixed in version: 4.07.0+dev/beta2/rc1/rc2
Category: typing
Duplicate of: #7138
Monitored by: @gasche
Bug description
When 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 reproduce
empty.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.
The text was updated successfully, but these errors were encountered: