(
expr: &Expr,
targets: FxHashSet<&'a ast::name::Name>,
direct_targets: FxHashSet<&'a ast::name::Name>,
ctx: &Ctx,
)
| 1200 | } |
| 1201 | |
| 1202 | fn check_rebound_variables<'a, Ctx: SemanticSyntaxContext>( |
| 1203 | expr: &Expr, |
| 1204 | targets: FxHashSet<&'a ast::name::Name>, |
| 1205 | direct_targets: FxHashSet<&'a ast::name::Name>, |
| 1206 | ctx: &Ctx, |
| 1207 | ) { |
| 1208 | let mut visitor = ReboundComprehensionVisitor { |
| 1209 | targets, |
| 1210 | direct_targets, |
| 1211 | ranges: Vec::new(), |
| 1212 | }; |
| 1213 | visitor.visit_expr(expr); |
| 1214 | |
| 1215 | // TODO(brent): With multiple diagnostic ranges, mark both the named expression target |
| 1216 | // (currently reported) and the comprehension target it rebinds. |
| 1217 | for range in visitor.ranges { |
| 1218 | // test_err rebound_comprehension_variable |
| 1219 | // [(a := 0) for a in range(0)] |
| 1220 | // {(a := 0) for a in range(0)} |
| 1221 | // {(a := 0): val for a in range(0)} |
| 1222 | // {key: (a := 0) for a in range(0)} |
| 1223 | // ((a := 0) for a in range(0)) |
| 1224 | // [[(a := 0)] for a in range(0)] |
| 1225 | // [(a := 0) for b in range (0) for a in range(0)] |
| 1226 | // [(a := 0) for a in range (0) for b in range(0)] |
| 1227 | // [((a := 0), (b := 1)) for a in range (0) for b in range(0)] |
| 1228 | |
| 1229 | // test_ok non_rebound_comprehension_variable |
| 1230 | // [a := 0 for x in range(0)] |
| 1231 | Self::add_error( |
| 1232 | ctx, |
| 1233 | SemanticSyntaxErrorKind::ReboundComprehensionVariable, |
| 1234 | range, |
| 1235 | ); |
| 1236 | } |
| 1237 | } |
| 1238 | |
| 1239 | fn check_class_body_expr<Ctx: SemanticSyntaxContext>(expr: &Expr, ctx: &Ctx) { |
| 1240 | if !ctx.in_class_body_comprehension() { |
nothing calls this directly
no test coverage detected