This commit is contained in:
Folkert 2020-06-27 23:56:53 +02:00
parent 229d98483c
commit 55e1e86dc2
3 changed files with 17 additions and 10 deletions

View file

@ -388,7 +388,7 @@ pub fn assert_correct_variable_usage(constraint: &Constraint) {
println!("difference: {:?}", &diff);
// panic!("variable usage problem (see stdout for details)");
panic!("variable usage problem (see stdout for details)");
}
}

View file

@ -601,7 +601,8 @@ fn write_boolean(env: &Env, boolean: Bool, subs: &Subs, buf: &mut String, parens
buf.push_str("Shared");
}
Bool::Container(cvar, mvars) if mvars.iter().all(|v| var_is_shared(subs, *v)) => {
// Bool::Container(cvar, mvars) if mvars.is_empty() => {
debug_assert!(!var_is_shared(subs, cvar));
write_content(
env,
subs.get_without_compacting(cvar).content,
@ -611,8 +612,11 @@ fn write_boolean(env: &Env, boolean: Bool, subs: &Subs, buf: &mut String, parens
);
}
Bool::Container(cvar, mvars) => {
debug_assert!(!var_is_shared(subs, cvar));
let mut buffers = Vec::with_capacity(mvars.len());
for v in mvars {
// don't print shared in a container
if var_is_shared(subs, v) {
continue;
}
@ -625,11 +629,10 @@ fn write_boolean(env: &Env, boolean: Bool, subs: &Subs, buf: &mut String, parens
&mut inner_buf,
parens,
);
// buffers_set.insert(inner_buf);
buffers.push(inner_buf);
}
// let mut buffers: Vec<String> = buffers_set.into_iter().collect();
// sort type variables alphabetically
buffers.sort();
let combined = buffers.join(" | ");

View file

@ -67,10 +67,10 @@ macro_rules! mismatch {
type Pool = Vec<Variable>;
pub struct Context {
pub first: Variable,
pub first_desc: Descriptor,
pub second: Variable,
pub second_desc: Descriptor,
first: Variable,
first_desc: Descriptor,
second: Variable,
second_desc: Descriptor,
}
#[derive(Debug)]
@ -668,8 +668,10 @@ fn unify_flat_type(
outcome
}
(Container(cvar1, mvars1), Container(cvar2, mvars2)) => {
let mut outcome = vec![];
// unify cvar1 and cvar2?
unify_pool(subs, pool, *cvar1, *cvar2);
outcome.extend(unify_pool(subs, pool, *cvar1, *cvar2));
let mvars: SendSet<Variable> = mvars1
.into_iter()
@ -689,7 +691,9 @@ fn unify_flat_type(
let content =
Content::Structure(FlatType::Boolean(Bool::Container(*cvar1, mvars)));
merge(subs, ctx, content)
outcome.extend(merge(subs, ctx, content));
outcome
}
}
}