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

unused-field (69) and unused-constructor (37) can't be applied to individual fields/constructors #11235

Closed
Khady opened this issue May 3, 2022 · 3 comments · Fixed by #11864

Comments

@Khady
Copy link
Contributor

Khady commented May 3, 2022

Warnings 69 (introduced in #10232) and 37 have to be applied to whole types, they do not work on individual fields or constructors, which could sometimes be useful.

(* this one works as expected *)
type a = { foo: int; bar: int } [@@warning "-69"]

(* this one does nothing *)
type a' = { foo: int [@warning "-69"]; bar: int }

(* this one works as expected *)
type b =
  | A of string
  | B of int
[@@warning "-unused-constructor"]

(* this one does nothing *)
type b' = 
  | A of string [@warning "-unused-constructor"]
  | B of int
@Octachron
Copy link
Member

This sounds like sensible feature with straightforward implementation.
For interested outreachy students, the warnings are matched to the constructor Unused_constructor _ and Unused_field _ inside the compiler. The change requires to find the location where each warning is used and ensure that attributes on the constructor or labels are taken in account in the current warning scope.

@Oluwabukolab
Copy link
Contributor

I'd like to work on this issue.

@Octachron
Copy link
Member

Don't hesitate to go ahead then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants