From 18a64d88acf27a1b603d228cea4497e0e264683f Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Fri, 31 May 2024 18:04:46 -0600 Subject: [PATCH] add TODO comment about union-of-all-defs --- crates/red_knot/src/types/infer.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/red_knot/src/types/infer.rs b/crates/red_knot/src/types/infer.rs index c24f4b2fb9ba2..fd70a43ad667b 100644 --- a/crates/red_knot/src/types/infer.rs +++ b/crates/red_knot/src/types/infer.rs @@ -25,6 +25,10 @@ pub fn infer_symbol_public_type(db: &dyn SemanticDb, symbol: GlobalSymbolId) -> return Ok(ty); } + // The public type of a symbol is the union of all of its definitions. This is the most + // cautious/sound approach, though it can lead to a broader-than-desired type in a case like + // `x = 1; x = str(x)`, where the first definition of `x` can never be visible. TODO prune + // definitions that we can prove can't be visible. let tys = defs .iter() .map(|def| infer_definition_type(db, symbol, def.clone()))