This commit is contained in:
gluax 2022-05-23 19:01:07 -07:00
parent 019598c84e
commit ca3fb11bc3
2 changed files with 8 additions and 6 deletions

View File

@ -168,14 +168,14 @@ impl<'a> TypeChecker<'a> {
let t1 = self.compare_expr_type(&binary.left, None, binary.left.span());
let t2 = self.compare_expr_type(&binary.right, None, binary.right.span());
// Allow `group` * `scalar` multiplication.
match (t1.as_ref(), t2.as_ref()) {
(Some(Type::Group), Some(other)) => {
self.assert_type(t1.unwrap(), expected, binary.left.span());
self.assert_type(*other, Some(Type::Scalar), binary.span());
Some(Type::Group)
} (Some(other), Some(Type::Group)) => {
}
(Some(other), Some(Type::Group)) => {
self.assert_type(t2.unwrap(), expected, binary.left.span());
self.assert_type(*other, Some(Type::Scalar), binary.span());
Some(Type::Group)

View File

@ -78,9 +78,11 @@ impl<'a> TypeChecker<'a> {
pub(crate) fn assert_eq_types(&self, t1: Option<Type>, t2: Option<Type>, span: Span) {
match (t1, t2) {
(Some(t1), Some(t2)) if t1 != t2 => self.handler
(Some(t1), Some(t2)) if t1 != t2 => self
.handler
.emit_err(TypeCheckerError::type_should_be(t1, t2, span).into()),
(Some(type_), None) | (None, Some(type_)) => self.handler
(Some(type_), None) | (None, Some(type_)) => self
.handler
.emit_err(TypeCheckerError::type_should_be("no type", type_, span).into()),
_ => {}
}