-
Notifications
You must be signed in to change notification settings - Fork 701
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
Only munge internal dependencies when printing when there is no explicit syntax #10287
Merged
+9
−6
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I updated your PR description a bit to properly format the code blocks, I was not understanding what you were describing because lines were missing in the rendered markdown. |
geekosaur
approved these changes
Aug 27, 2024
mpickering
commented
Aug 28, 2024
Mikolaj
approved these changes
Aug 28, 2024
fgaz
reviewed
Sep 3, 2024
Cabal-syntax/src/Distribution/PackageDescription/PrettyPrint.hs
Outdated
Show resolved
Hide resolved
#10285 (comment) re the merge conflict: |
mergify
bot
added
the
ready and waiting
Mergify is waiting out the cooldown period
label
Jan 13, 2025
mpickering
force-pushed
the
wip/t10283
branch
from
January 13, 2025 14:41
c0c7db6
to
d629f5a
Compare
I have rebased and assigned the merge label. |
mergify
bot
added
the
merge delay passed
Applied (usually by Mergify) when PR approved and received no updates for 2 days
label
Jan 15, 2025
mpickering
force-pushed
the
wip/t10283
branch
from
January 17, 2025 10:58
d629f5a
to
6092e31
Compare
…cit syntax * In `postProcessInternalDeps` the shadowing logic which existed prior to cabal format 3.4 is implemented in a post processing step. The algorithm there replaces any references to internal sublibraries with an explicit qualifier. For example if you write.. ``` library build-depends: foo library foo ... ``` this is reinterpreted as ``` library build-depends: mylib:foo library foo ... ``` * In `preProcessInternalDeps` the inverse transformation takes place, the goal is to replace `mylib:foo` with just `foo`. * Things go wrong if you are using version 3.0 for your cabal file because - In 3.0 the qualifier syntax is introduced so you can be expliciit about sublibrary dependencies - The shadowing semantics of non-qualified dependencies still exists. So the situation is that the user is explicit about the sublibrary ``` library library qux build-depends: mylib:{mylib, foo} library foo ``` 1. Post-process leaves this alone, the user is already explicit about depending on a sublibrary. 2. Pre-processing then rewrites `mylib:{mylib, foo}` into two dependencies, `mylib` and `foo` (no qualifier). 3. When parsed these are two separate dependencies rather than treated as one dependency, roundtrip test fails. Solution: Only perform the reverse transformation when the cabal library version is <= 3.0 and doesn't support the explicit syntax. Now what happens in these two situations: 1. ``` library build-depends: foo library foo ... ``` this is reinterpreted as ``` library build-depends: mylib:foo library foo ... ``` then printed and parsed exactly the same way. 2. Explicit syntax is parsed and printed without being munged (when supported) Note: Mixins only supported sublibrary qualifiers from 3.4 whilst dependencies supported this from 3.0, hence the lack of guard on the mixins case. Fixes #10283
mpickering
force-pushed
the
wip/t10283
branch
from
January 17, 2025 11:01
6092e31
to
4019d17
Compare
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 me
Tell Mergify Bot to merge
ready and waiting
Mergify is waiting out the cooldown period
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Only munge internal dependencies when printing when there is no explicit syntax
In
postProcessInternalDeps
the shadowing logic which existed prior to cabal format 3.4 is implemented in a post processing step.The algorithm there replaces any references to internal sublibraries with an explicit qualifier. For example if you write..
this is reinterpreted as
In
preProcessInternalDeps
the inverse transformation takes place, the goal is to replacemylib:foo
with justfoo
.Things go wrong if you are using version 3.0 for your cabal file because
So the situation is that the user is explicit about the sublibrary
mylib:{mylib, foo}
into two dependencies,mylib
andfoo
(no qualifier).Solution: Only perform the reverse transformation when the cabal library version is <= 3.0 and doesn't support the explicit syntax.
Now what happens in these two situations:
this is reinterpreted as
then printed and parsed exactly the same way.
Explicit syntax is parsed and printed without being munged (when supported)
Note: Mixins only supported sublibrary qualifiers from 3.4 whilst dependencies supported this from 3.0, hence the lack of guard on the mixins case.
Fixes #10283
Please read Github PR Conventions and then fill in one of these two templates.
Template Α: This PR modifies behaviour or interface
Include the following checklist in your PR:
Template B: This PR does not modify behaviour or interface
E.g. the PR only touches documentation or tests, does refactorings, etc.
Include the following checklist in your PR: