fix problem with patterns and optional record fields

This commit is contained in:
Folkert 2020-11-09 01:04:40 +01:00
parent 099c56fcf6
commit 4868c0bd25
2 changed files with 10 additions and 3 deletions

View file

@ -384,6 +384,7 @@ fn unify_shared_fields(
// Unifying X with X => X
let actual = match (actual, expected) {
(Demanded(_), Optional(_)) | (Optional(_), Demanded(_)) => {
// this is an error, but we continue to give better error messages
continue;
}
(Demanded(val), Required(_))
@ -395,7 +396,8 @@ fn unify_shared_fields(
(Optional(val), Optional(_)) => Optional(val),
};
matching_fields.insert(name, actual);
let existing = matching_fields.insert(name, actual);
debug_assert_eq!(existing, None);
}
}
@ -412,7 +414,7 @@ fn unify_shared_fields(
merge(subs, ctx, Structure(flat_type))
} else {
mismatch!()
mismatch!("in unify_shared_fields")
}
}