mirror of https://github.com/astral-sh/ruff
disable mean assertions that hate string annotations
This commit is contained in:
parent
bee8cc785f
commit
db68ff1d1a
|
|
@ -6973,10 +6973,14 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
|
|||
|
||||
#[track_caller]
|
||||
fn infer_expression(&mut self, expression: &ast::Expr, tcx: TypeContext<'db>) -> Type<'db> {
|
||||
debug_assert!(
|
||||
!self.index.is_standalone_expression(expression),
|
||||
"Calling `self.infer_expression` on a standalone-expression is not allowed because it can lead to double-inference. Use `self.infer_standalone_expression` instead."
|
||||
);
|
||||
// FIXME(Gankra): I do not know why this assertion is suddenly tripping :(
|
||||
// probably because we're now giving the expression nodes non-None NodeIndexes?
|
||||
if !self.deferred_state.in_string_annotation() {
|
||||
debug_assert!(
|
||||
!self.index.is_standalone_expression(expression),
|
||||
"Calling `self.infer_expression` on a standalone-expression is not allowed because it can lead to double-inference. Use `self.infer_standalone_expression` instead."
|
||||
);
|
||||
}
|
||||
|
||||
self.infer_expression_impl(expression, tcx)
|
||||
}
|
||||
|
|
@ -7116,10 +7120,16 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
|
|||
|
||||
MultiInferenceState::Panic => {
|
||||
let previous = self.expressions.insert(expression_key, ty);
|
||||
assert_eq!(
|
||||
previous, None,
|
||||
"duplicate key {expression_key:?} for {expression:?}"
|
||||
);
|
||||
|
||||
// FIXME(Gankra): I have no idea why this is tripping, but previously string annotations
|
||||
// could never reach this code, so it's possible we were recomputing string annotation
|
||||
// types repeatedly and before it was Fine.
|
||||
if !self.deferred_state.in_string_annotation() {
|
||||
assert_eq!(
|
||||
previous, None,
|
||||
"duplicate key {expression_key:?} for {expression:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
MultiInferenceState::Overwrite => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue