Type analysis on branches is inconsistent depending on whether an explicit return is used #46061
Labels
A-inference
Area: Type inference
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I would expect the following two snippets of code to behave the same:
But in reality, the first snippet works fine, and the second fails because the typechecker cannot unify
std::boxed::Box<futures::FutureResult<std::string::String, _>>
withstd::boxed::Box<futures::Future<Item=std::string::String, Error=std::string::String>>
. Given that the typechecker can and does unify them in the first case, it seems it should be able to do the same in the second case. Whether I use an implicit or explicit return shouldn't change the type analysis being done.The text was updated successfully, but these errors were encountered: