WIP - Debug tuples

This commit is contained in:
David Mak 2024-08-12 17:27:22 +08:00
parent de21aaf907
commit fea0a6934e
1 changed files with 13 additions and 10 deletions

View File

@ -805,15 +805,18 @@ fn polymorphic_print<'ctx>(
match &*ctx.unifier.get_ty_immutable(ty) {
TypeEnum::TTuple { ty: tys, is_vararg_ctx: false } => {
debug_assert_eq!(
tys.len() as u32,
value.into_struct_value().count_fields(),
"Expected {} types for {}, got [{}] ({} types) in corresponding LLVM type",
tys.len(),
ctx.unifier.stringify(ty),
value.into_struct_value().get_fields().map(|field| field.get_type().to_string()).join(", "),
value.into_struct_value().count_fields(),
);
let value = value.into_struct_value();
println!("value: {:?}", value.get_type());
// debug_assert_eq!(
// tys.len() as u32,
// value.into_struct_value().count_fields(),
// "Expected {} types for {}, got [{}] ({} types) in corresponding LLVM type",
// tys.len(),
// ctx.unifier.stringify(ty),
// value.into_struct_value().get_fields().map(|field| field.get_type().to_string()).join(", "),
// value.into_struct_value().count_fields(),
// );
fmt.push('(');
flush(ctx, generator, &mut fmt, &mut args);
@ -825,7 +828,7 @@ fn polymorphic_print<'ctx>(
(
*ty,
unsafe {
ValueEnum::from(value.into_struct_value().get_field_at_index_unchecked(i as u32))
ValueEnum::from(value.get_field_at_index_unchecked(i as u32))
},
)
})