Skip to main content

haloumi_ir/
error.rs

1//! Error type.
2
3use std::convert::Infallible;
4
5use thiserror::Error;
6
7use crate::{expr::NonConstIRBexprError, meta::Meta};
8
9/// IR error type.
10#[derive(Error, Clone, Debug)]
11pub enum Error {
12    /// Happens while lowering [`IRBexpr`](crate::expr::IRBexpr) with no arguments (i.e. an empty
13    /// `and` expression).
14    #[error("boolean expression with no elements")]
15    EmptyBexpr,
16    /// Happens while constant folding a [`IRBexpr`](crate::expr::IRBexpr) that folds into `false`.
17    #[error("{2}: detected {0} statement with predicate evaluating to 'false': {1}")]
18    FoldedFalseStmt(&'static str, String, Meta),
19    /// Happens when a boolean expression is not constant and was expected to be.
20    #[error(transparent)]
21    ExpectedConstBexpr(#[from] NonConstIRBexprError),
22}
23
24impl From<Infallible> for Error {
25    fn from(_value: Infallible) -> Self {
26        unreachable!()
27    }
28}