Skip to content

handle conditionals in duplicate module checks #7616

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

Merged
merged 5 commits into from
Sep 7, 2021
Merged

Conversation

gbaz
Copy link
Collaborator

@gbaz gbaz commented Sep 3, 2021

Resolves #4629

This is a less invasive approach than my last pass. It only factors out the duplicate module checks without touching anything else. This is a better "rough cut" approximation but still not perfect. In particular, It won't generate duplicate module warnings from a module existing on both sides of an if/else conditional -- however, if there are distinct conditional blocks which logically are exclusive (i.e. one is a check on a positive condition and the other a check on its negation) it won't catch that by actually model-checking the various possible outcomes.

Copy link
Member

@emilypi emilypi left a comment

Choose a reason for hiding this comment

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

This looks good @gbaz. Clean solution

++ concatMap checkTest (map snd $ condTestSuites pkg)
++ concatMap checkBench (map snd $ condBenchmarks pkg)
where
-- the duplicate modules check is has not been thoroughly vetted for backpack
Copy link
Member

Choose a reason for hiding this comment

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

We can leave a TODO for that in the issues list if anyone wants to check it out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this was me migrating the old comment -- the current logic is no worse than before, but i didn't want to lose a potential warning here :-)

@emilypi
Copy link
Member

emilypi commented Sep 4, 2021

Tho we do need a changelog.

@Mikolaj Mikolaj self-requested a review September 6, 2021 13:03
Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

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

Great job, this produces much better approximation, while staying linear and improving code quality.

checkTest = checkDups "test suite" testModules
checkBench = checkDups "benchmark" benchmarkModules
checkDups s getModules t =
let libMap = foldCondTree Map.empty
Copy link
Member

Choose a reason for hiding this comment

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

Why such an enormous indent? (Also, two spaces after arrow on the line below, but only one space before comments (feel free to ignore).)

@gbaz gbaz added the squash+merge me Tell Mergify Bot to squash-merge label Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attention: needs-review squash+merge me Tell Mergify Bot to squash-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cabal check doesn't account for conditionals
3 participants