[ty] Fix panic for cyclic star imports (#21428)

This commit is contained in:
Micha Reiser 2025-11-13 15:38:09 +01:00 committed by GitHub
parent a01b0d7780
commit 67e54fffe1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,7 +39,13 @@ pub(super) fn exported_names(db: &dyn Db, file: File) -> Box<[Name]> {
let module = parsed_module(db, file).load(db);
let mut finder = ExportFinder::new(db, file);
finder.visit_body(module.suite());
finder.resolve_exports()
let mut exports = finder.resolve_exports();
// Sort the exports to ensure convergence regardless of hash map
// or insertion order. See <https://github.com/astral-sh/ty/issues/444>
exports.sort_unstable();
exports.into()
}
struct ExportFinder<'db> {
@ -69,7 +75,7 @@ impl<'db> ExportFinder<'db> {
}
}
fn resolve_exports(self) -> Box<[Name]> {
fn resolve_exports(self) -> Vec<Name> {
match self.dunder_all {
DunderAll::NotPresent => self
.exports