diff --git a/compiler/noirc_frontend/src/hir/type_check/errors.rs b/compiler/noirc_frontend/src/hir/type_check/errors.rs index ece3a4c61ef..41e0e8e0079 100644 --- a/compiler/noirc_frontend/src/hir/type_check/errors.rs +++ b/compiler/noirc_frontend/src/hir/type_check/errors.rs @@ -6,6 +6,7 @@ use thiserror::Error; use crate::hir::resolution::errors::ResolverError; use crate::hir_def::expr::HirBinaryOp; use crate::hir_def::types::Type; +use crate::BinaryOpKind; use crate::FunctionReturnType; use crate::Signedness; @@ -23,8 +24,8 @@ pub enum Source { StringLen, #[error("Comparison")] Comparison, - #[error("BinOp")] - BinOp, + #[error("{0}")] + BinOp(BinaryOpKind), #[error("Return")] Return(FunctionReturnType, Span), } @@ -218,7 +219,7 @@ impl From for Diagnostic { Source::ArrayLen => format!("Can only compare arrays of the same length. Here LHS is of length {expected}, and RHS is {actual}"), Source::StringLen => format!("Can only compare strings of the same length. Here LHS is of length {expected}, and RHS is {actual}"), Source::Comparison => format!("Unsupported types for comparison: {expected} and {actual}"), - Source::BinOp => format!("Unsupported types for binary operation: {expected} and {actual}"), + Source::BinOp(kind) => format!("Unsupported types for operator `{kind}`: {expected} and {actual}"), Source::Return(ret_ty, expr_span) => { let ret_ty_span = match ret_ty.clone() { FunctionReturnType::Default(span) => span, diff --git a/compiler/noirc_frontend/src/hir/type_check/expr.rs b/compiler/noirc_frontend/src/hir/type_check/expr.rs index 16e8f2d4200..02241434729 100644 --- a/compiler/noirc_frontend/src/hir/type_check/expr.rs +++ b/compiler/noirc_frontend/src/hir/type_check/expr.rs @@ -1060,8 +1060,6 @@ impl<'interner> TypeChecker<'interner> { Err(TypeCheckError::InvalidInfixOp { kind: "Tuples", span }) } - (Unit, _) | (_, Unit) => Ok(Unit), - // The result of two Fields is always a witness (FieldElement, FieldElement) => { if op.is_bitwise() { @@ -1075,7 +1073,7 @@ impl<'interner> TypeChecker<'interner> { (lhs, rhs) => Err(TypeCheckError::TypeMismatchWithSource { expected: lhs.clone(), actual: rhs.clone(), - source: Source::BinOp, + source: Source::BinOp(op.kind), span, }), }