use thiserror::Error;
use crate::ast::{AstBindingRef, AstDialectVersion, AstNameRef};
use crate::hir::HirProtoRef;
#[derive(Debug, Error)]
pub enum GenerateError {
#[error("generate cannot find naming context for proto#{function}")]
MissingFunctionNames { function: usize },
#[error("generate cannot resolve name {name:?} in proto#{function}")]
MissingName { function: usize, name: AstNameRef },
#[error("generate cannot resolve binding {binding:?} in proto#{function}")]
MissingBindingName {
function: usize,
binding: AstBindingRef,
},
#[error("generate encountered residual temp name {name:?} in proto#{function}")]
ResidualTempName { function: usize, name: AstNameRef },
#[error("generate encountered residual temp binding {binding:?} in proto#{function}")]
ResidualTempBinding {
function: usize,
binding: AstBindingRef,
},
#[error(
"generate encountered mixed global attributes in a single declaration in proto#{function}"
)]
MixedGlobalAttrs { function: usize },
#[error(
"target dialect `{dialect}` does not support feature `{feature}` required during generate"
)]
UnsupportedFeature {
dialect: AstDialectVersion,
feature: &'static str,
},
}
impl GenerateError {
pub(crate) fn missing_function_names(function: HirProtoRef) -> Self {
Self::MissingFunctionNames {
function: function.index(),
}
}
}