mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
better debug info for a mismatch
This commit is contained in:
parent
19d56fa7d4
commit
aa042f3357
2 changed files with 18 additions and 2 deletions
|
@ -327,6 +327,14 @@ fn subs_fmt_desc(this: &Descriptor, subs: &Subs, f: &mut fmt::Formatter) -> fmt:
|
|||
write!(f, " m: {:?}", &this.mark)
|
||||
}
|
||||
|
||||
pub struct SubsFmtContent<'a>(pub &'a Content, pub &'a Subs);
|
||||
|
||||
impl<'a> fmt::Debug for SubsFmtContent<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
subs_fmt_content(self.0, self.1, f)
|
||||
}
|
||||
}
|
||||
|
||||
fn subs_fmt_content(this: &Content, subs: &Subs, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match this {
|
||||
Content::FlexVar(name) => write!(f, "Flex({:?})", name),
|
||||
|
@ -345,6 +353,14 @@ fn subs_fmt_content(this: &Content, subs: &Subs, f: &mut fmt::Formatter) -> fmt:
|
|||
}
|
||||
}
|
||||
|
||||
pub struct SubsFmtFlatType<'a>(pub &'a FlatType, pub &'a Subs);
|
||||
|
||||
impl<'a> fmt::Debug for SubsFmtFlatType<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
subs_fmt_flat_type(self.0, self.1, f)
|
||||
}
|
||||
}
|
||||
|
||||
fn subs_fmt_flat_type(this: &FlatType, subs: &Subs, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match this {
|
||||
FlatType::Apply(name, arguments) => {
|
||||
|
|
|
@ -1076,8 +1076,8 @@ fn unify_flat_type(
|
|||
// any other combination is a mismatch
|
||||
mismatch!(
|
||||
"Trying to unify two flat types that are incompatible: {:?} ~ {:?}",
|
||||
other1,
|
||||
other2
|
||||
roc_types::subs::SubsFmtFlatType(other1, subs),
|
||||
roc_types::subs::SubsFmtFlatType(other2, subs)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue