Skip to content

fix panic: Key Anon already exists with value ClassDef w/ NamedTuple and assert #4447 - #4456

Closed
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:4447
Closed

fix panic: Key Anon already exists with value ClassDef w/ NamedTuple and assert #4447#4456
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:4447

Conversation

@asukaminato0721

Copy link
Copy Markdown
Collaborator

Summary

Fixes #4447

Removed redundant anonymous binding for assert conditions, preventing collision with synthesized NamedTuple bindings.

Test Plan

add test

@meta-codesync

meta-codesync Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D114829883. (Because this pull request was imported automatically, there will not be any future comments.)

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@yangdanny97

Copy link
Copy Markdown
Contributor

The anon binding was there for catching type errors in the test expression. Can you verify that an assert test w/ a type error still gets flagged?

@asukaminato0721

Copy link
Copy Markdown
Collaborator Author

The anon binding was there for catching type errors in the test expression. Can you verify that an assert test w/ a type error still gets flagged?

yes, cargo test -p pyrefly --lib test::simple::test_assert -- --exact --nocapture works

because

BindingExpect::Bool(x) => {
let ty = self.expr_infer(x, errors);

@yangdanny97 yangdanny97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

@meta-codesync meta-codesync Bot closed this in f7e444a Aug 5, 2026
@meta-codesync meta-codesync Bot added the Merged label Aug 5, 2026
@meta-codesync

meta-codesync Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This pull request has been merged in f7e444a.

@asukaminato0721
asukaminato0721 deleted the 4447 branch August 5, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: Key Anon already exists with value ClassDef w/ NamedTuple and assert

2 participants