mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 00:09:33 +03:00
Merge pull request #223 from rtfeldman/various-bugfixes
Various bugfixes
This commit is contained in:
commit
15092e7424
@ -707,17 +707,24 @@ fn call_successors<'a>(
|
||||
call_symbol: Symbol,
|
||||
closures: &'a MutMap<Symbol, References>,
|
||||
) -> ImSet<Symbol> {
|
||||
// TODO (this comment should be moved to a GH issue) this may cause an infinite loop if 2 definitions reference each other; may need to track visited definitions!
|
||||
match closures.get(&call_symbol) {
|
||||
Some(references) => {
|
||||
let mut answer = local_successors(&references, closures);
|
||||
let mut answer = im_rc::hashset::HashSet::default();
|
||||
let mut seen = MutSet::default();
|
||||
let mut queue = vec![call_symbol];
|
||||
|
||||
answer.insert(call_symbol.clone());
|
||||
|
||||
answer
|
||||
while let Some(symbol) = queue.pop() {
|
||||
if seen.contains(&symbol) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(references) = closures.get(&symbol) {
|
||||
answer.extend(references.lookups.iter().copied());
|
||||
queue.extend(references.calls.iter().copied());
|
||||
|
||||
seen.insert(symbol);
|
||||
}
|
||||
None => ImSet::default(),
|
||||
}
|
||||
|
||||
answer
|
||||
}
|
||||
|
||||
pub fn references_from_local<'a, T>(
|
||||
|
@ -18,7 +18,7 @@ use roc_region::all::{Located, Region};
|
||||
#[derive(Debug)]
|
||||
pub struct ModuleOutput {
|
||||
pub aliases: MutMap<Symbol, Alias>,
|
||||
pub rigid_variables: MutMap<Lowercase, Variable>,
|
||||
pub rigid_variables: MutMap<Variable, Lowercase>,
|
||||
pub declarations: Vec<Declaration>,
|
||||
pub exposed_imports: MutMap<Symbol, Variable>,
|
||||
pub lookups: Vec<(Symbol, Variable, Region)>,
|
||||
@ -121,7 +121,7 @@ pub fn canonicalize_module_defs<'a>(
|
||||
}
|
||||
}
|
||||
|
||||
for (var, lowercase) in output.rigids.clone() {
|
||||
for (var, lowercase) in output.ftv.clone() {
|
||||
rigid_variables.insert(var, lowercase);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ pub struct Module {
|
||||
pub exposed_vars_by_symbol: Vec<(Symbol, Variable)>,
|
||||
pub references: MutSet<Symbol>,
|
||||
pub aliases: MutMap<Symbol, Alias>,
|
||||
pub rigid_variables: MutMap<Lowercase, Variable>,
|
||||
pub rigid_variables: MutMap<Variable, Lowercase>,
|
||||
pub imported_modules: MutSet<ModuleId>,
|
||||
}
|
||||
|
||||
@ -859,7 +859,7 @@ fn solve_module(
|
||||
|
||||
let mut subs = Subs::new(var_store.into());
|
||||
|
||||
for (name, var) in module.rigid_variables {
|
||||
for (var, name) in module.rigid_variables {
|
||||
subs.rigid_var(var, name);
|
||||
}
|
||||
|
||||
|
@ -246,8 +246,8 @@ fn unify_record(
|
||||
let other_fields = union(unique_fields1.clone(), &unique_fields2);
|
||||
|
||||
let ext = fresh(subs, pool, ctx, Content::FlexVar(None));
|
||||
let flat_type1 = FlatType::Record(unique_fields1, rec1.ext);
|
||||
let flat_type2 = FlatType::Record(unique_fields2, rec2.ext);
|
||||
let flat_type1 = FlatType::Record(unique_fields1, ext);
|
||||
let flat_type2 = FlatType::Record(unique_fields2, ext);
|
||||
|
||||
let sub1 = fresh(subs, pool, ctx, Structure(flat_type1));
|
||||
let sub2 = fresh(subs, pool, ctx, Structure(flat_type2));
|
||||
|
Loading…
Reference in New Issue
Block a user