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

Erroneous warning on unused private constructor #5596

Closed
vicuna opened this issue Apr 18, 2012 · 2 comments
Closed

Erroneous warning on unused private constructor #5596

vicuna opened this issue Apr 18, 2012 · 2 comments
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Apr 18, 2012

Original bug ID: 5596
Reporter: @yakobowski
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2013-08-31T10:49:04Z)
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

---------- mli -------------
module C : sig
type t
val inject : t
end
---------- ml -------------
module C : sig
type t = private I
val inject : t
end =
struct
type t = I
let inject = I
end
let _v = C.inject

Constructor I is incorrectly marked as unused.

Additional information

Svn 12372

@vicuna
Copy link
Author

vicuna commented Apr 18, 2012

Comment author: @alainfrisch

Well spotted. In your example, it is not wrong to say that I is unused (you can turn the private definition in an abstract one!). But clearly, something is wrong: if there were other constructors in the same sum type, it would not possible to remove that one (and one might want to use this constructor only in patterns). I think one needs a different treatment for sum type definitions in module interfaces so as not to report them as being unused.

Another example is:

module F(X : sig type t = A | B end) = struct
let f = function X.A -> 0 | X.B -> 1
end

@vicuna
Copy link
Author

vicuna commented Apr 18, 2012

Comment author: @alainfrisch

Fixed in trunk (commit 12378) and 4.00 (commit 12379). Constructors in signatures are no longer reported as unused.

@vicuna vicuna closed this as completed Aug 31, 2013
@vicuna vicuna added the bug label Mar 20, 2019
dra27 pushed a commit to dra27/ocaml that referenced this issue Feb 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants