Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Nov 13, 2025

Summary

Fixes astral-sh/ty#444

This PR fixes a panic where the export_names query never converged for a cyclic star import.

This is a rather silly bug. The cycle never converged because the symbol ordering changed between iterations (forever)....

Here's a diff between the exported symbols before the fix for the last two iterations

https://www.diffchecker.com/tk3ihAdo/

This PR fixes the bug by simply sorting the names before returning.

I considered using a BTreeMap but found the sort slightly simpler (and both roughly have the same complexity)

Test Plan

I recreated the MRE from the linked issue and verified that it panics without my changes.

@MichaReiser MichaReiser added bug Something isn't working ty Multi-file analysis & type inference labels Nov 13, 2025
@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 13, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 13, 2025

mypy_primer results

Changes were detected when running on open source projects
scikit-build-core (https://github.com/scikit-build/scikit-build-core)
+ src/scikit_build_core/build/wheel.py:98:20: error[no-matching-overload] No overload of bound method `__init__` matches arguments
- Found 44 diagnostics
+ Found 45 diagnostics

No memory usage changes detected ✅

@AlexWaygood
Copy link
Member

Oh, wow, and the iteration order matters because the query itself returns Box<[Name]> rather than returning the FxHashMap directly (because if it returned the FxHashMap directly, two maps with the same entries would still compare equal even if they were differently ordered)... what a bug.....

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

brilliant

@MichaReiser
Copy link
Member Author

MichaReiser commented Nov 13, 2025

Come on Github... start those CI jobs. I want to see the perf impact.

@MichaReiser MichaReiser force-pushed the micha/fix-exported-names-too-many-iterations branch from d905851 to 14294a1 Compare November 13, 2025 14:18
@MichaReiser MichaReiser merged commit 67e54ff into main Nov 13, 2025
41 checks passed
@MichaReiser MichaReiser deleted the micha/fix-exported-names-too-many-iterations branch November 13, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[panic] Panic 'too many cycle iterations' for recursive star import

3 participants