Improve error messages for typerefs a bit

This commit is contained in:
Sofia 2025-07-20 21:51:18 +03:00
parent c0e375d84c
commit 62d73b19a2
2 changed files with 13 additions and 6 deletions

View File

@ -311,3 +311,13 @@ fn write_access(f: &mut std::fmt::Formatter<'_>, name: &String) -> std::fmt::Res
f.write_char('.')?;
Display::fmt(name, f)
}
impl std::fmt::Display for VagueType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
VagueType::Unknown => write!(f, "Unknown"),
VagueType::Number => write!(f, "Number"),
VagueType::TypeRef(_) => write!(f, "{{unknown}}"),
}
}
}

View File

@ -113,17 +113,14 @@ pub enum TypeKind {
Borrow(Box<TypeKind>),
#[error("Ptr({0})")]
Ptr(Box<TypeKind>),
#[error(transparent)]
Vague(#[from] VagueType),
#[error("{0}")]
Vague(VagueType),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error, PartialOrd, Ord, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum VagueType {
#[error("Unknown")]
Unknown,
#[error("Number")]
Number,
#[error("TypeRef({0})")]
TypeRef(usize),
}