panic: key lacking binding with fuzzed assignment expressions and comprehensions
Describe the Bug
Pyrefly crashes when checking this fuzzed code:
[(c:=)for c+]
[(c:=)for]
ERROR Thread panicked, shutting down: panicked at pyrefly/lib/binding/bindings.rs:518:13:
Internal error: key lacking binding, module=__unknown__, path=/home/user/crash.py, key=Key::Anywhere(c 1:3-4), key-debug=Anywhere((Name("c"), 2..3))
Version info
Reproducible with 1.1.0.dev1 and commit 9ef0830d5
Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIA2gBQDGiAvAJRi4BOABLQNQC6AOuhr1mrNgPQgANCDJsYYKKUIAXXAFsoFAMQcACqXmLSHNFjz4uudJADmAVzaoVEa4UG6AyjBgcAFioqxHCIAPShcgpKhOy2oTDooZi4tHChtNZ2js6uiRxiHKgAbqjQqNiwVjYQDk4u1hy4xPXocO7oZCp%2B1gC0RTBscLkcDBz8IADMhACMAEzjgpQDbOxwEvboEOrE7CowmD2YEPK0Lv0jHADkNejsMJeCtyo98gCO9sf7PQDWMKQ9qFotHgcAulwA7qg2OgHpIAL4yQFnGAAMWgMAoZhwBBI5DhQA
(Only applicable for extension issues) IDE Information
No response
I can take this.
This issue has someone assigned, but has not had recent activity for more than 2 weeks.
If you are still working on this issue, please add a comment so everyone knows. Otherwise, please unassign yourself and allow someone else to take over.
Thank you for your contributions!
Hi @mikeleppane, are you still working on this one? We hit the same crash from #4403 and have a fix ready to put up. Happy to hold off if you're close, otherwise we'll go ahead later this week.
Thanks for the report @correctmost! The crash came from a walrus inside a comprehension not being recorded in the outer scope when the name is assigned more than once. @mikeleppane, we haven't heard back since September, so we've put up a fix and this will close once it lands.