diff --git a/compiler/solve/src/solve.rs b/compiler/solve/src/solve.rs index 6afb812a78..aa5488b7eb 100644 --- a/compiler/solve/src/solve.rs +++ b/compiler/solve/src/solve.rs @@ -428,6 +428,7 @@ impl Env { it1.zip(it2) } + #[inline(always)] fn get_var_by_symbol(&self, symbol: &Symbol) -> Option { self.symbols .iter() @@ -435,6 +436,7 @@ impl Env { .map(|index| self.variables[index]) } + #[inline(always)] fn insert_symbol_var_if_vacant(&mut self, symbol: Symbol, var: Variable) { match self.symbols.iter().position(|s| *s == symbol) { None => { @@ -725,23 +727,27 @@ fn solve( // check that things went well debug_assert!({ - // NOTE the `subs.redundant` check is added for the uniqueness - // inference, and does not come from elm. It's unclear whether this is - // a bug with uniqueness inference (something is redundant that - // shouldn't be) or that it just never came up in elm. let rigid_vars = &constraints.variables[let_con.rigid_vars.indices()]; - let failing: Vec<_> = rigid_vars + // NOTE the `subs.redundant` check does not come from elm. + // It's unclear whether this is a bug with our implementation + // (something is redundant that shouldn't be) + // or that it just never came up in elm. + let mut it = rigid_vars .iter() .filter(|&var| !subs.redundant(*var) && subs.get_rank(*var) != Rank::NONE) - .collect(); + .peekable(); - if !failing.is_empty() { + if it.peek().is_some() { + let failing: Vec<_> = it.collect(); println!("Rigids {:?}", &rigid_vars); println!("Failing {:?}", failing); - } - failing.is_empty() + // nicer error message + failing.is_empty() + } else { + true + } }); let mut new_env = env.clone(); diff --git a/compiler/types/src/types.rs b/compiler/types/src/types.rs index fd8d9e12f0..2c73f95435 100644 --- a/compiler/types/src/types.rs +++ b/compiler/types/src/types.rs @@ -2270,7 +2270,11 @@ pub fn gather_fields_unsorted_iter( Structure(Record(sub_fields, sub_ext)) => { stack.push(*sub_fields); - var = *sub_ext; + if var == Variable::EMPTY_RECORD { + break; + } else { + var = *sub_ext; + } } Alias(_, _, actual_var, _) => {