Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positives 'unused type/constructor/value' using 4.06.0+beta1 #7656

Closed
vicuna opened this issue Oct 10, 2017 · 3 comments
Closed

False positives 'unused type/constructor/value' using 4.06.0+beta1 #7656

vicuna opened this issue Oct 10, 2017 · 3 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Oct 10, 2017

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

@vicuna
Copy link
Author

vicuna commented Oct 11, 2017

Comment author: jpdeplaix

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

@vicuna
Copy link
Author

vicuna commented Oct 11, 2017

Comment author: @alainfrisch

Likely caused by commit e286dbd, cf #7620 and the discussion #1317 . The point is that warnings should not be enabled when using -i .

@vicuna
Copy link
Author

vicuna commented Oct 11, 2017

Comment author: @alainfrisch

#1423

@vicuna vicuna closed this as completed Oct 13, 2017
@vicuna vicuna added the typing label Mar 14, 2019
@vicuna vicuna added this to the 4.06.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants