-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[ty] fix binary expression inference between boolean literals and bool instances #18663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…e issue that coerces the inferred type to 'int' when the right side is a nominal instance such as a function call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for identifying the bug and proposing a fix! I think we want to adjust a few things in this PR, but it's a great start.
|
… change the inference logic to be more general
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
…ol' in order to trigger regression properly, change the integer casting logic to cast when the operator is not 'BitOr | BitAnd | BitXor' or when the other operand is an 'IntLiteral'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you!
Summary
This PR fixes a false type inference issue specified in astral-sh/ty#649
If there is a better solution, I'm open to implementing that too. The current version uses the right-hand-side type when it finds a
bool & NominalInstance
pair, which is an improvement over the previous version, but I'm guessing there are bugs introduces by this too. I will keep inspecting those as I wait for the reviews.Closes astral-sh/ty#649
Test Plan
This PR was tested through a regression test, added as an inline test to the module.