[red-knot] Infer lambda return type as Unknown (#16695)

## Summary

Part of #15382

This PR infers the return type `lambda` expression as `Unknown`. In the
future, it would be more useful to infer the expression type considering
the surrounding context (#16696).

## Test Plan

Update existing test cases from `@todo` to the (verified) return type.
This commit is contained in:
Dhruv Manilawala
2025-03-18 22:48:10 +05:30
committed by GitHub
parent c3d429ddd8
commit a69f6240cc
2 changed files with 16 additions and 13 deletions

View File

@@ -3840,9 +3840,12 @@ impl<'db> TypeInferenceBuilder<'db> {
Parameters::empty()
};
// TODO: Useful inference of a lambda's return type will require a different approach,
// which does the inference of the body expression based on arguments at each call site,
// rather than eagerly computing a return type without knowing the argument types.
Type::Callable(CallableType::General(GeneralCallableType::new(
self.db(),
Signature::new(parameters, Some(todo_type!("lambda return type"))),
Signature::new(parameters, Some(Type::unknown())),
)))
}