From db68ff1d1a0e1c651b418c7f7902ca9a119a6dc9 Mon Sep 17 00:00:00 2001 From: Aria Desires Date: Tue, 2 Dec 2025 15:17:09 -0500 Subject: [PATCH] disable mean assertions that hate string annotations --- .../src/types/infer/builder.rs | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index 09758ad43a..9484f1061e 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -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 => {