27 lines
700 B
Rust
27 lines
700 B
Rust
use crate::ast::Type;
|
|
|
|
#[derive(Debug, PartialEq, Eq, thiserror::Error)]
|
|
pub enum AnalysisErrorTag {
|
|
#[error("Mismatching types in function return.")]
|
|
MismatchingTypesFunctionReturn,
|
|
#[error("Insufficient bits in type {1} for constant with {0} bits")]
|
|
InsufficientBitsInTypeForConstant(u32, Type),
|
|
}
|
|
|
|
#[derive(Debug, PartialEq, Eq, thiserror::Error)]
|
|
pub struct AnalysisError {
|
|
inner: AnalysisErrorTag,
|
|
}
|
|
|
|
impl AnalysisError {
|
|
pub fn new(inner: AnalysisErrorTag) -> Self {
|
|
Self { inner }
|
|
}
|
|
}
|
|
|
|
impl core::fmt::Display for AnalysisError {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
core::fmt::Debug::fmt(&self.inner, f)
|
|
}
|
|
}
|