mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
various small type-related changes
This commit is contained in:
parent
9cb6261a4d
commit
21a51464f3
2 changed files with 20 additions and 10 deletions
|
@ -428,6 +428,7 @@ impl Env {
|
||||||
it1.zip(it2)
|
it1.zip(it2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn get_var_by_symbol(&self, symbol: &Symbol) -> Option<Variable> {
|
fn get_var_by_symbol(&self, symbol: &Symbol) -> Option<Variable> {
|
||||||
self.symbols
|
self.symbols
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -435,6 +436,7 @@ impl Env {
|
||||||
.map(|index| self.variables[index])
|
.map(|index| self.variables[index])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn insert_symbol_var_if_vacant(&mut self, symbol: Symbol, var: Variable) {
|
fn insert_symbol_var_if_vacant(&mut self, symbol: Symbol, var: Variable) {
|
||||||
match self.symbols.iter().position(|s| *s == symbol) {
|
match self.symbols.iter().position(|s| *s == symbol) {
|
||||||
None => {
|
None => {
|
||||||
|
@ -725,23 +727,27 @@ fn solve(
|
||||||
|
|
||||||
// check that things went well
|
// check that things went well
|
||||||
debug_assert!({
|
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 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()
|
.iter()
|
||||||
.filter(|&var| !subs.redundant(*var) && subs.get_rank(*var) != Rank::NONE)
|
.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!("Rigids {:?}", &rigid_vars);
|
||||||
println!("Failing {:?}", failing);
|
println!("Failing {:?}", failing);
|
||||||
}
|
|
||||||
|
|
||||||
failing.is_empty()
|
// nicer error message
|
||||||
|
failing.is_empty()
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut new_env = env.clone();
|
let mut new_env = env.clone();
|
||||||
|
|
|
@ -2270,7 +2270,11 @@ pub fn gather_fields_unsorted_iter(
|
||||||
Structure(Record(sub_fields, sub_ext)) => {
|
Structure(Record(sub_fields, sub_ext)) => {
|
||||||
stack.push(*sub_fields);
|
stack.push(*sub_fields);
|
||||||
|
|
||||||
var = *sub_ext;
|
if var == Variable::EMPTY_RECORD {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
var = *sub_ext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Alias(_, _, actual_var, _) => {
|
Alias(_, _, actual_var, _) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue