fix: disregard type variable expectation for if expressions

This commit is contained in:
Ryo Yoshida 2022-11-01 00:15:05 +09:00
parent d022e0ec53
commit db8c7523f8
No known key found for this signature in database
GPG key ID: E25698A930586171
2 changed files with 34 additions and 0 deletions

View file

@ -85,6 +85,7 @@ impl<'a> InferenceContext<'a> {
let ty = match &self.body[tgt_expr] {
Expr::Missing => self.err_ty(),
&Expr::If { condition, then_branch, else_branch } => {
let expected = &expected.adjust_for_branches(&mut self.table);
self.infer_expr(
condition,
&Expectation::has_type(TyKind::Scalar(Scalar::Bool).intern(Interner)),