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

Allow explicit dependencies to resolve ambiguities #20853

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lilatomic
Copy link
Contributor

In case of an ambiguous dependency inference, we give the help text:

Please explicitly include the dependency you want in the dependencies field of a:a, or ignore the ones you do not want by prefixing with ! or !! so that one or no targets are left.

However, adding an explicit dependency doesn't actually resolve that.
In ExplicitlyProvidedDependencies.disambiguated, if the target is in the explicitly provided dependencies, we just return. This results in the dependency being unowned, but included because of the explicit dependency link.

This MR rebuilds that function to use the explicitly provided dependencies to attempt to resolve an ambiguity. The logic is now as follows:

  1. If there are no ambiguities, return
  2. Use excludes to eliminate candidates. If there is a single owner, return it
  3. Use includes to filter the remaining candidates (after excludes). If there is a single owner, return it

This algorithm change does result in changes to dependency inference. We can now resolve a situation which had both includes and excludes, and the excludes would resolve it. Previously, this would not be resolved.
I don't think this will result in other changes in resolution. (I considered the case of the same address being included and excluded, but it seems that the excludes currently functionally take priority).

fixes #20806

out.add(addr)
maybe_tgt_generator = addr.maybe_convert_to_target_generator()
if maybe_tgt_generator in self.includes:
# TODO: do we include the maybe_tgt_generator or the addr?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm honestly not sure about this. I should also probably add a test to pin down the desired behaviour

@huonw huonw added this to the 2.20.x milestone Apr 28, 2024
@huonw
Copy link
Contributor

huonw commented Apr 28, 2024

(Thanks for looking at this, given #20806 affects 2.20.0, I've pre-emptively labelled this for cherry-picking back to that branch.)

@lilatomic lilatomic marked this pull request as draft May 2, 2024 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants