Handle not-in operator

This commit is contained in:
Arthur Targaryen
2021-10-09 17:58:58 +02:00
parent 5f9ad0947d
commit 9e7e8ed48f
4 changed files with 70 additions and 2 deletions

View File

@ -295,6 +295,28 @@ pub fn math_result_type(
)
}
},
Operator::NotIn => match (&lhs.ty, &rhs.ty) {
(t, Type::List(u)) if type_compatible(t, u) => (Type::Bool, None),
(Type::Int | Type::Float, Type::Range) => (Type::Bool, None),
(Type::String, Type::String) => (Type::Bool, None),
(Type::String, Type::Record(_, _)) => (Type::Bool, None),
(Type::Unknown, _) => (Type::Bool, None),
(_, Type::Unknown) => (Type::Bool, None),
_ => {
*op = Expression::garbage(op.span);
(
Type::Unknown,
Some(ParseError::UnsupportedOperation(
op.span,
lhs.span,
lhs.ty.clone(),
rhs.span,
rhs.ty.clone(),
)),
)
}
},
_ => {
*op = Expression::garbage(op.span);