fix: Implement Expactation::Castable and add a test case for it

This commit is contained in:
Lukas Wirth 2023-02-08 12:57:08 +01:00
parent 5e6208b1df
commit f8f1cb93e0
3 changed files with 41 additions and 8 deletions

View file

@ -610,9 +610,9 @@ impl<'a> InferenceContext<'a> {
}
}
Expr::Cast { expr, type_ref } => {
// FIXME: propagate the "castable to" expectation (and find a test case that shows this is necessary)
let _inner_ty = self.infer_expr_inner(*expr, &Expectation::none());
let cast_ty = self.make_ty(type_ref);
let _inner_ty =
self.infer_expr_inner(*expr, &Expectation::Castable(cast_ty.clone()));
// FIXME check the cast...
cast_ty
}