-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] do nothing with store_expression_type if inner_expression_inference_state is Get
#21718
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
base: main
Are you sure you want to change the base?
Conversation
…erence_state` is `Get`
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
| fn store_expression_type(&mut self, expression: &ast::Expr, ty: Type<'db>) { | ||
| if self.deferred_state.in_string_annotation() { | ||
| if self.deferred_state.in_string_annotation() | ||
| || self.inner_expression_inference_state.is_get() |
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.
Could we use multi_inference_state::Ignore instead of having two modes that represent "read-only" type inference?
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.
drive-by context: I am likely to modify this check for in_string_annotation to do the "store (Expr, Expr) for string annotation types" thing we've been discussing.
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.
Could we use
multi_inference_state::Ignoreinstead of having two modes that represent "read-only" type inference?
I understand that MultiInferenceState::Ignore is an option to perform the same calculation twice and discard the second result.
Since all type inference for expressions is skipped while in InnerExpressionInferenceState::Get, I think it should be used whenever possible (for example, when only diagnostics are needed, such as the handling in infer_subscript_type_expression for union types).
But I'm not sure whether this can be assumed in all cases where MultiInferenceState::Ignore is used.
Summary
Fixes astral-sh/ty#1688
Test Plan
N/A