diff --git a/crates/red_knot_python_semantic/resources/mdtest/invalid_syntax.md b/crates/red_knot_python_semantic/resources/mdtest/invalid_syntax.md index 2363257e7eb87..e33b7cb81990e 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/invalid_syntax.md +++ b/crates/red_knot_python_semantic/resources/mdtest/invalid_syntax.md @@ -26,13 +26,10 @@ def True(for): # error: [invalid-syntax] pass -# TODO: Why is there two diagnostics for the same error? - # error: [invalid-syntax] # error: [invalid-syntax] # error: [invalid-syntax] # error: [unresolved-reference] "Name `pass` used when not defined" -# error: [unresolved-reference] "Name `pass` used when not defined" for while in pass: pass @@ -58,12 +55,10 @@ match while: ### Attribute expression ```py -# TODO: Why is there two diagnostics for the same error? # TODO: Check when support for attribute expressions is added # error: [invalid-syntax] # error: [unresolved-reference] "Name `foo` used when not defined" -# error: [unresolved-reference] "Name `foo` used when not defined" for x in foo.pass: pass ``` diff --git a/crates/red_knot_python_semantic/src/types/infer.rs b/crates/red_knot_python_semantic/src/types/infer.rs index 2173e0edf64b9..afdd60e8292ff 100644 --- a/crates/red_knot_python_semantic/src/types/infer.rs +++ b/crates/red_knot_python_semantic/src/types/infer.rs @@ -1900,12 +1900,11 @@ impl<'db> TypeInferenceBuilder<'db> { is_async: _, } = for_statement; - self.infer_standalone_expression(iter); - // TODO more complex assignment targets if let ast::Expr::Name(name) = &**target { self.infer_definition(name); } else { + self.infer_standalone_expression(iter); self.infer_expression(target); } self.infer_body(body);