Skip to content

Commit ec74f2d

Browse files
authored
Revert "[red-knot] Type narrowing for assertions (#17149)" (#17335)
I merged #17149 without checking the ecosystem results, and it still caused a cycle panic in pybind11. Reverting for now until I fix that, so we don't lose the ecosystem signal on other PRs.
1 parent 907b6ed commit ec74f2d

File tree

3 files changed

+2
-65
lines changed

3 files changed

+2
-65
lines changed

crates/red_knot_python_semantic/resources/mdtest/narrow/assert.md

-53
This file was deleted.

crates/red_knot_python_semantic/src/semantic_index/builder.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ impl<'db> SemanticIndexBuilder<'db> {
534534
}
535535

536536
/// Records a visibility constraint by applying it to all live bindings and declarations.
537+
#[must_use = "A visibility constraint must always be negated after it is added"]
537538
fn record_visibility_constraint(
538539
&mut self,
539540
predicate: Predicate<'db>,
@@ -1291,17 +1292,6 @@ where
12911292
);
12921293
}
12931294
}
1294-
1295-
ast::Stmt::Assert(node) => {
1296-
self.visit_expr(&node.test);
1297-
let predicate = self.record_expression_narrowing_constraint(&node.test);
1298-
self.record_visibility_constraint(predicate);
1299-
1300-
if let Some(msg) = &node.msg {
1301-
self.visit_expr(msg);
1302-
}
1303-
}
1304-
13051295
ast::Stmt::Assign(node) => {
13061296
debug_assert_eq!(&self.current_assignments, &[]);
13071297

crates/red_knot_python_semantic/src/types/infer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3188,7 +3188,7 @@ impl<'db> TypeInferenceBuilder<'db> {
31883188
msg,
31893189
} = assert;
31903190

3191-
let test_ty = self.infer_standalone_expression(test);
3191+
let test_ty = self.infer_expression(test);
31923192

31933193
if let Err(err) = test_ty.try_bool(self.db()) {
31943194
err.report_diagnostic(&self.context, &**test);

0 commit comments

Comments
 (0)