aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty.rs
diff options
context:
space:
mode:
authorMarcus Klaas de Vries <[email protected]>2019-01-05 20:28:30 +0000
committerMarcus Klaas de Vries <[email protected]>2019-01-05 20:28:30 +0000
commit4fc233a02e8dc07619a969400c445ec47c2b1a9d (patch)
treedae33907a38b7c4ed9d1a63ff38803e99f1ae6df /crates/ra_hir/src/ty.rs
parent3e42a158787955ff9f2e81be43479dbe8f2b1bb6 (diff)
Implement type inference for boolean operators
Diffstat (limited to 'crates/ra_hir/src/ty.rs')
-rw-r--r--crates/ra_hir/src/ty.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index e33762e0d..718e193f7 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -26,7 +26,7 @@ use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError};
26 26
27use ra_db::{LocalSyntaxPtr, Cancelable}; 27use ra_db::{LocalSyntaxPtr, Cancelable};
28use ra_syntax::{ 28use ra_syntax::{
29 ast::{self, AstNode, LoopBodyOwner, ArgListOwner, PrefixOp}, 29 ast::{self, AstNode, LoopBodyOwner, ArgListOwner, PrefixOp, BinOp},
30 SyntaxNodeRef 30 SyntaxNodeRef
31}; 31};
32 32
@@ -906,7 +906,16 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
906 } 906 }
907 } 907 }
908 ast::Expr::RangeExpr(_e) => Ty::Unknown, 908 ast::Expr::RangeExpr(_e) => Ty::Unknown,
909 ast::Expr::BinExpr(_e) => Ty::Unknown, 909 ast::Expr::BinExpr(e) => match e.op() {
910 Some(BinOp::BooleanOr)
911 | Some(BinOp::BooleanAnd)
912 | Some(BinOp::EqualityTest)
913 | Some(BinOp::LesserEqualTest)
914 | Some(BinOp::GreaterEqualTest)
915 | Some(BinOp::LesserTest)
916 | Some(BinOp::GreaterTest) => Ty::Bool,
917 _ => Ty::Unknown,
918 },
910 ast::Expr::Literal(_e) => Ty::Unknown, 919 ast::Expr::Literal(_e) => Ty::Unknown,
911 }; 920 };
912 // use a new type variable if we got Ty::Unknown here 921 // use a new type variable if we got Ty::Unknown here