forked from libre-chip/fayalite
check types in debug mode in impl Debug for Expr, helping to catch bugs
This commit is contained in:
parent
122c08d3cf
commit
4eda4366c8
1 changed files with 11 additions and 0 deletions
|
@ -274,6 +274,17 @@ pub struct Expr<T: Type> {
|
|||
|
||||
impl<T: Type + fmt::Debug> fmt::Debug for Expr<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
let Self {
|
||||
__enum,
|
||||
__ty,
|
||||
__flow,
|
||||
} = self;
|
||||
let expr_ty = __ty.canonical();
|
||||
let enum_ty = __enum.to_expr().__ty;
|
||||
assert_eq!(expr_ty, enum_ty, "expr ty mismatch:\nExpr {{\n__enum: {__enum:?},\n__ty: {__ty:?},\n__flow: {__flow:?}\n}}");
|
||||
}
|
||||
self.__enum.fmt(f)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue