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

Satisfy -Werror=unused-top-binds #9488

Merged
merged 1 commit into from
Dec 28, 2023

Conversation

philderbeast
Copy link
Collaborator

@philderbeast philderbeast commented Dec 1, 2023

Satisfy the build with this (uncommited) change:

git diff
diff --git a/cabal.project b/cabal.project
index d0b2fbabc..c0695f378 100644
--- a/cabal.project
+++ b/cabal.project
@@ -20,4 +20,4 @@ constraints: rere -rere-cfg
 constraints: these -assoc
 
 program-options
-  ghc-options: -fno-ignore-asserts
+  ghc-options: -fno-ignore-asserts -Werror=unused-top-binds

We can pick up the deleted top binds of Cabal-tests/tests/UnitTests/Distribution/Simple/Program/GHC.hs in #9435.

@Mikolaj
Copy link
Member

Mikolaj commented Dec 2, 2023

Could you elaborate? Does it break CI or your local tests? Only with some GHCs?

@philderbeast
Copy link
Collaborator Author

The unused top binds are dead code.

@Mikolaj
Copy link
Member

Mikolaj commented Dec 2, 2023

Oh, I see! If you do the change cited in the description, then compilation would error and your PR fixes the error by removing dead code. Did I get it right?

And the dead code is worrying, because it suggests some old changes have been misapplied or corrupted, right? Should we maybe not remove the dead code until we investigate and either plug it back in or decide it's unneeded?

@philderbeast philderbeast force-pushed the werror=unused-top-binds branch from ad2046f to e693aaa Compare December 19, 2023 16:37
Copy link
Collaborator

@ulysses4ever ulysses4ever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me quite a while to understand the motivation just by reading the description, unfortunately.

For the context: we already use -Werror for the main packages in this repo -- see cabal.project.validate. This patch explores a partial -Werror for a test package. So, the natural question is: why actually not go further and add that partial -Werror for the test package in cabal.project.validate?..

@philderbeast
Copy link
Collaborator Author

@ulysses4ever at the time I didn't want to delve into the various projects and their purpose so instead I showed how I found there was dead code.

$ tree -P 'cabal.project*' --prune -L 1
.
├── cabal.project
├── cabal.project.buildinfo
├── cabal.project.coverage
├── cabal.project.doctest
├── cabal.project.latest-ghc
├── cabal.project.libonly
├── cabal.project.meta
├── cabal.project.release
├── cabal.project.validate
├── cabal.project.validate.libonly
└── cabal.project.weeder

1 directory, 11 files

The cabal.project.validate project has -Werror for some of its packages but this won't trigger -Werror=unused-top-binds. We'd need to flag -Wunused-top-binds or -Wunused-binds or -Wextra to include those warnings. We don't set a warning level in that project so will be getting warnings included in -Wdefault (from GHC's Warnings and sanity-checking).

@philderbeast
Copy link
Collaborator Author

Label merge+no rebase is necessary when the pull request is from an organisation.

@philderbeast
Copy link
Collaborator Author

For the context: we already use -Werror for the main packages in this repo -- see cabal.project.validate. This patch explores a partial -Werror for a test package. So, the natural question is: why actually not go further and add that partial -Werror for the test package in cabal.project.validate?..

Thanks for suggesting this @ulysses4ever. I reviewed the projects with #9565 but have not yet got around to changing the warning levels (except using ghc-options: -Werror from program-options instead of doing it more explicitly per package).

@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Dec 28, 2023
@mergify mergify bot merged commit ce5d0f7 into haskell:master Dec 28, 2023
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge+no rebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants