Add debug assertion for shape of tag union extension variables

When we have a tag union type, outside of special cases in the middle of
unification, its extension type should either be (1) the closed tag
union or (2) a flex/rigid var. This adds an assertion for that.
This commit is contained in:
Ayaz Hafiz 2023-01-12 16:05:32 -06:00
parent 1c58118dc7
commit 5f5d6a42d1
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58

View file

@ -4263,9 +4263,18 @@ pub fn gather_tags_unsorted_iter(
let mut stack = vec![other_fields];
#[cfg(debug_assertions)]
let mut seen_head_union = false;
loop {
match subs.get_content_without_compacting(var) {
Structure(TagUnion(sub_fields, sub_ext)) => {
#[cfg(debug_assertions)]
{
assert!(!seen_head_union, "extension variable is another tag union, but I expected it to be either open or closed!");
seen_head_union = true;
}
stack.push(*sub_fields);
var = *sub_ext;