Skip to content

Categorize KeyExpect uses and use distinct enum variants #2208

@stroxler

Description

@stroxler

Better Engineering task

I ran into a panic while working on a new feature caused by the fact that Pyrefly's architecture assumes we will never have two KeyExpects with the same location.

This is obviously not a very scalable invariant - it's a global properly of binding logic, impossible to verify by just skimming code. I know that my feature ran into a case where this is violated, but it's actually entirely possible that edge cases already exist which are just extremely rare that cause crashes.

We should just use an enum with good tags for different kinds of expectations to make this problem vastly less likely.

Assigning to myself - I can do this, but it has to happen after some of my current work is merged

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions