Skip to content

Fix the duplicate modules check #7966

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 2 commits into from
Mar 26, 2022
Merged

Fix the duplicate modules check #7966

merged 2 commits into from
Mar 26, 2022

Conversation

gbaz
Copy link
Collaborator

@gbaz gbaz commented Feb 10, 2022

Resolves #7776

Now if a package may have duplicate modules (subject to conditionals), cabal warns on this.

But if a package necessarily has duplicate modules (because they are not guarded by conditionals), cabal will error.

@Mikolaj Mikolaj requested a review from andreasabel February 11, 2022 00:21
Copy link
Member

@andreasabel andreasabel left a comment

Choose a reason for hiding this comment

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

I don't understand the code, but I tested the product on hashable-1.2.7 and hashable-1.3 and found now that it works as expected: build and install succeed, check gives this warning:

Warning: Potential duplicate modules (subject to conditionals) in benchmark:
Data.Hashable.RandomSource

in if not (null dupLibsLax)
then [PackageBuildImpossible $ "Duplicate modules in " ++ s ++ ": " ++ commaSep (map prettyShow dupLibsLax)]
else if not (null dupLibsStrict)
then [PackageDistSuspicious $ "Potential duplicate modules (subject to conditionals) in " ++ s ++ ": " ++ commaSep (map prettyShow dupLibsStrict)]
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be PackageDistInexcusable, since in this case there's a branch where modules are duplicated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Inexecusable would prevent hackage upload. Given that people can write multiple if branches that are not obviously nonexclusive, but whose conditions (e.g. ghc versions) logically can't all be satisfied at once, this would make the check more restrictive than prior. So e.g. ghc-src-gen could be built but not uploaded. One could argue this would be cleaner, but my goal was to clarify existing checks and allow more clearly legit stuff to pass, not to add any new restrictions.

@fgaz
Copy link
Member

fgaz commented Feb 12, 2022

Could you post hackage-tests results ( #7776 (comment) ) with master, master with this patch, and master with #7616 reverted?

@gbaz
Copy link
Collaborator Author

gbaz commented Feb 15, 2022

Master without this patch has 1116 build impossible. With it, there are only 525 build impossible, with the remaining 591 are now marked as suspicious.

So that seems about right.

@fgaz
Copy link
Member

fgaz commented Feb 15, 2022

What is the number with #7616 reverted?

@gbaz
Copy link
Collaborator Author

gbaz commented Feb 24, 2022

Damn it, i ran that test the other day and then forgot to post the results, which are now on a lost terminal. But the build impossible was no less than with this patch, and perhaps even the exact same -- i.e. the results tied out as one would hope.

@jneira
Copy link
Member

jneira commented Mar 10, 2022

@Mergifyio rebase master

@mergify
Copy link
Contributor

mergify bot commented Mar 10, 2022

rebase master

✅ Branch has been successfully rebased

@jneira jneira force-pushed the gb/fix-dup-check-2 branch from edd300b to a58592e Compare March 10, 2022 17:11
Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

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

not fully understand the code neither but trust it 🙂
but I think this really need a changelog entry and a regression test, based in the hashable case f.e., bonus if it tests the warning

@jneira jneira added this to the Considered for 3.8 milestone Mar 10, 2022
Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

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

I think this really need a changelog entry and a regression test, based in the hashable case f.e., bonus if it tests the warning

jneira added a commit to jneira/cabal that referenced this pull request Mar 17, 2022
@jneira
Copy link
Member

jneira commented Mar 18, 2022

@Mergifyio rebase master

@mergify
Copy link
Contributor

mergify bot commented Mar 18, 2022

rebase master

✅ Branch has been successfully rebased

@jneira jneira force-pushed the gb/fix-dup-check-2 branch from a58592e to 0480612 Compare March 18, 2022 21:57
jneira added a commit to jneira/cabal that referenced this pull request Mar 21, 2022
@jneira
Copy link
Member

jneira commented Mar 21, 2022

What is the number with #7616 reverted?

Full hackage test check data for each case at index 2022-02-28T05:16:39Z

  • with master:
D:\ws\haskell\cabal>cabal run Cabal-tests:hackage-tests -- check
Up to date
Reading index from: D:\cabal\packages\hackage.haskell.org\01-index.tar
157946 files processed
42067 files have lexer/parser warnings
115687 files have check warnings
1118 build impossible
7980 build warning
51952 build dist suspicious
36949 build dist suspicious warning
17688 build dist inexcusable
  • with this pr:
157946 files processed
42067 files have lexer/parser warnings
115687 files have check warnings
525 build impossible
7980 build warning
52545 build dist suspicious
36949 build dist suspicious warning
17688 build dist inexcusable
157946 files processed
42067 files have lexer/parser warnings
114905 files have check warnings
336 build impossible
7980 build warning
51952 build dist suspicious
36949 build dist suspicious warning
17688 build dist inexcusable

//cc @fgaz

@jneira jneira mentioned this pull request Mar 21, 2022
@gbaz
Copy link
Collaborator Author

gbaz commented Mar 25, 2022

@Mergifyio rebase master

@mergify
Copy link
Contributor

mergify bot commented Mar 25, 2022

rebase master

✅ Branch has been successfully rebased

@jneira jneira force-pushed the gb/fix-dup-check-2 branch from 0480612 to d3a6c09 Compare March 25, 2022 21:33
Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for the fix

@andreasabel
Copy link
Member

Great to see this fixed!

BEFORE:

Configuring library for snap-server-1.1.2.0..
Error: cabal: Duplicate modules in library: System.SendFile

Duplicate modules in executable: System.SendFile

Duplicate modules in executable: System.SendFile

Duplicate modules in test suite: System.SendFile, System.SendFile.Tests

AFTER: works!

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

Successfully merging this pull request may close these issues.

Regression on master: building hashable-1.3.0.0 fails with Duplicate modules in benchmark
4 participants