Skip to content

Fix loose mode fallback resolution - #110

Merged
Boshen merged 2 commits into
yarnpkg:mainfrom
Freakazo:fix-loose-mode-fallback-resolution
Jul 22, 2026
Merged

Fix loose mode fallback resolution#110
Boshen merged 2 commits into
yarnpkg:mainfrom
Freakazo:fix-loose-mode-fallback-resolution

Conversation

@Freakazo

@Freakazo Freakazo commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • match the Yarn reference PnP runtime by resolving loose-mode fallbacks from the top-level locator before the deduplicated fallback pool
  • avoid applying fallback resolution when the issuer is the top-level package itself
  • preserve undeclared and unfulfilled-peer states while evaluating fallbacks

Closes #111

@Freakazo

Freakazo commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

I think this could be done cleaner with

enum FallbackResolution {
    Missing,
    Unbound,
    Resolved(PackageDependency),
}

and

match resolve_via_fallback(manifest, &ident) {
    FallbackResolution::Resolved(binding) => {
        reference_or_alias = Some(binding);
        is_set = true;
    }
    FallbackResolution::Unbound => {
        reference_or_alias = None;
        is_set = true;
    }
    FallbackResolution::Missing => {}
}

Instead of using Option<Option< to convey the same, but I'm not a Rust expert so I leave it up to the reviewer to decide.

@Freakazo

Copy link
Copy Markdown
Contributor Author

I went ahead with enum DependencyResolution to make the code easier to reason about (Atlast for me)

@Freakazo

Freakazo commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@Boshen hoping to get a review for this

@Boshen
Boshen merged commit 08f44c3 into yarnpkg:main Jul 22, 2026
6 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loose-mode fallback resolution can select the wrong dependency version

3 participants