-
Notifications
You must be signed in to change notification settings - Fork 98
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
Add driver flag to force opting in to unused code warnings in derived code #490
Conversation
By the way, something that didn't occur to me initially, if you prefer this can be merged into the existing flag, by making the cli ui Edit: I did that in the PR. changing the existing |
3e50763
to
395b6ef
Compare
Noting some action item for me to look into next on this PR:
|
395b6ef
to
9ddfd49
Compare
@NathanReb thanks for #492 ! I like your proposed new tests a lot, and found it makes adding tests for this PR easier. By the way, do you like to use cram tests as characterization tests in the ppxlib project? If so, I'd like to propose to include to the new |
I think the If it's not asking too much though, I would prefer if those were added in a separate PR from this one! |
@mbarbin do you want to keep working on this? I'd like to include this into the next release! I'm of course happy to take over if you're too busy at the moment! |
Hi @NathanReb thanks so much for the heads up ! I am traveling at the moment and it would be difficult for me to allocate time to get it done before the release. I appreciate your offer to take over, and would be glad if you do for this time. Looking at my action items, last time I checked:
The first one was merged, but I noticed there was some formatting change further done in 493, thus I waited to be sure it would be included before rebasing onto it. I think the formatting change were minimal and shouldn't be an issue.
You can simply delete the changes related to this, there's no time pressure on this. I'll simply resume this in a separate PR at a later point.
I did this, and left some remark for you to review, with the understanding that adding a third value was backward compatible. Again, thanks a lot. I appreciate your work on ppxlib! |
@NathanReb One more thing while I am thinking about it : do as it is the most convenient for you, please do not worry about keeping or rebasing my commits, especially if it is just simpler to start over from a clean slate in another PR. I can close my draft and/or salvage things I'd like to extract later. Thank you! |
9ddfd49
to
022c671
Compare
Hi @NathanReb just the heads up I found some time to make progress on the action items and pushed an update. |
Awesome, I'll take a look! |
@mbarbin could you rebase on top of main? I'm actually thinking about dropping the The type one is likely to be harmless to the vast majority of users so I'm not sure how worth it is to complexify this whole thing with yet another flag. Some users want the same transition scenario than with the other warnings so it also allows to reuse the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good to me! Thanks for taking the time to add this feature!
Except for the Options
submodule name this is good to go once we've rebased it on top of main. I'll work on adding the unused type warning control under this same flag!
@NathanReb thank you for the review!
The latest update rebased on top of the
I agree with the harmless part of the type one, however I am under the impression that disabling the code warning is likely to require more work on the user side of things. For example, I tried on my code base to use If you are thinking about dropping the ability to control the unused type warning in isolation, then, I would advocate for resurrecting the PR #495 that changes the nature of the code, so we can close #473.
This sounds interesting. Can you say a bit more about this, I'd like to understand this in more details. Thanks a lot! |
bed8100
to
c0b1b82
Compare
…n derived code - Add tests - Add new flag in doc - Update CHANGES.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: Mathieu Barbin <[email protected]>
c0b1b82
to
489daff
Compare
@NathanReb I removed the part about |
Ok I undestand your point about merging the two flags and I agree user will have an easier time disabling the unused type warning silencing than the other two. How about making the
It's simply the feature where both the user and the derivers being used need to opt out of the warning silencing (except when The idea is that users can pass the flag with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
If I understand correctly, this is a slight twist to the earliest proposal that had
This sounds good to me! |
- Fix a bug where `Code_path.main_module_name` would not properly remove extensions from the filename and therefore return an invalid module name. (ocaml-ppx/ppxlib#512, @NathanReb) - Add `-unused-type-warnings` flag to the driver to allow users to disable only the generation of warning 34 silencing structure items when using `[@@deriving ...]` on type declarations. (ocaml-ppx/ppxlib#511, @mbarbin, @NathanReb) - Make `-unused-code-warnings` flag to the driver also controls the generation of warning 34 silencing structure items when using `[@@deriving ...]` on type declarations. (ocaml-ppx/ppxlib#510, @mbarbin, @NathanReb) - Driver: Add `-unused-code-warnings=force` command-line flag argument. (ocaml-ppx/ppxlib#490, @mbarbin) - new functions `Ast_builder.{e,p}list_tail` that take an extra tail expression/pattern argument parameter compared to `Ast_builder.{e,p}list`, so they can build ASTs like `a :: b :: c` instead of only `[ a; b ]`. (ocaml-ppx/ppxlib#498, ocaml-ppx/ppxlib#502, @v-gb, @NathanReb) - Fix `Longident.parse` so it also handles indexing operators such as `.!()`, `.%(;..)<-`, or `Vec.(.%())` (ocaml-ppx/ppxlib#494, @Octachron) - Add a `special_function'` variant which directly takes a `Longident.t` argument to avoid the issue that `Longident.t` cover distinct syntaxic classes which cannot be easily parsed by a common parser (ocaml-ppx/ppxlib#496, @Octachron). - Keep location ranges consistent when migrating `Pexp_function` nodes from 5.2+ to older versions (ocaml-ppx/ppxlib#504, @jchavarri) - Fix `-locations-check` behaviour so it is no longer required to pass `-check` as well to enable location checks. (ocaml-ppx/ppxlib#506, @NathanReb) Signed-off-by: Nathan Rebours <[email protected]>
- Fix a bug where `Code_path.main_module_name` would not properly remove extensions from the filename and therefore return an invalid module name. (ocaml-ppx/ppxlib#512, @NathanReb) - Add `-unused-type-warnings` flag to the driver to allow users to disable only the generation of warning 34 silencing structure items when using `[@@deriving ...]` on type declarations. (ocaml-ppx/ppxlib#511, @mbarbin, @NathanReb) - Make `-unused-code-warnings` flag to the driver also controls the generation of warning 34 silencing structure items when using `[@@deriving ...]` on type declarations. (ocaml-ppx/ppxlib#510, @mbarbin, @NathanReb) - Driver: Add `-unused-code-warnings=force` command-line flag argument. (ocaml-ppx/ppxlib#490, @mbarbin) - new functions `Ast_builder.{e,p}list_tail` that take an extra tail expression/pattern argument parameter compared to `Ast_builder.{e,p}list`, so they can build ASTs like `a :: b :: c` instead of only `[ a; b ]`. (ocaml-ppx/ppxlib#498, ocaml-ppx/ppxlib#502, @v-gb, @NathanReb) - Fix `Longident.parse` so it also handles indexing operators such as `.!()`, `.%(;..)<-`, or `Vec.(.%())` (ocaml-ppx/ppxlib#494, @Octachron) - Add a `special_function'` variant which directly takes a `Longident.t` argument to avoid the issue that `Longident.t` cover distinct syntaxic classes which cannot be easily parsed by a common parser (ocaml-ppx/ppxlib#496, @Octachron). - Keep location ranges consistent when migrating `Pexp_function` nodes from 5.2+ to older versions (ocaml-ppx/ppxlib#504, @jchavarri) - Fix `-locations-check` behaviour so it is no longer required to pass `-check` as well to enable location checks. (ocaml-ppx/ppxlib#506, @NathanReb) Signed-off-by: Nathan Rebours <[email protected]>
To quote the documentation recently added for the disable warning flags:
This PR adds a new value for the flag, in addition to
true|false
, it addsforce
which allows to force enabling unused code warnings even when the deriver arg was set tofalse
. See the 2 new lines in the table documenting the combination ofDeriver arg
andDriver Flag
:Motivation:
This is a PR that was prompted by the discussion in #473
In particular, I am interested to see what is the result of enabling unused code warnings locally without requiring the PPX author opt-in part of it.