Ok, with some more tests I realized it was specifically the --infer argument from menhir that causes the issue.
I tested with a small file to avoid menhir and directly use -i from the compiler:
Test file:
type t = Test
let f = fun Test -> ()
The command/result:
$ ocamlc -w A-4 -i test.ml
File "test.ml", line 1, characters 0-13:
Warning 37: constructor Test is never used to build values.
(However, this constructor appears in patterns.)
File "test.ml", line 2, characters 4-5:
Warning 32: unused value f.
type t = Test
val f : t -> unit
Original bug ID: 7656
Reporter: jpdeplaix
Assigned to: @alainfrisch
Status: resolved (set by @alainfrisch on 2017-10-13T19:01:32Z)
Resolution: fixed
Priority: normal
Severity: minor
Target version: 4.06.0 +dev/beta1/beta2/rc1
Fixed in version: 4.06.0 +dev/beta1/beta2/rc1
Category: typing
Monitored by: @gasche @yakobowski
Bug description
The attached menhir test-case produces false-positive warnings when all warnings are activated.
Steps to reproduce
By compiling the attached menhir file using ocamlbuild:
ocamlbuild -use-menhir -tag "warn(A-4)" parser.cmo
We get the following warnings:
File "parser.ml", line 2, characters 0-30:
Warning 34: unused type token.
File "parser.ml", line 2, characters 0-30:
Warning 37: unused constructor Test.
File "parser.ml", line 2, characters 0-30:
Warning 37: unused constructor EOF.
File "parser.ml", line 6, characters 4-23:
Warning 32: unused value menhir_begin_marker.
File "parser.ml", line 9, characters 4-11:
Warning 32: unused value xv_main.
File "parser.ml", line 40, characters 4-21:
Warning 32: unused value menhir_end_marker.
Additional information
This does not appear with OCaml 4.05.0. Every unused type/constructor/value are used when looking at the code generated by menhir.
Also, I cannot find any of the values listed above, in the generated code (neither menhir_begin_marker, xv_main nor menhir_end_marker).
File attachments
The text was updated successfully, but these errors were encountered: