fix todos regarding InvalidCycle

This commit is contained in:
Folkert 2020-07-03 15:42:24 +02:00
parent 39b70232de
commit 744b8ce32b
3 changed files with 38 additions and 30 deletions

View file

@ -872,38 +872,35 @@ pub fn constrain_decls(
) -> Constraint {
let mut constraint = Constraint::SaveTheEnvironment;
let mut env = Env {
home,
rigids: ImMap::default(),
};
for decl in decls.iter().rev() {
// NOTE: rigids are empty because they are not shared between top-level definitions
// Clear the rigids from the previous iteration.
// rigids are not shared between top-level definitions
env.rigids.clear();
match decl {
Declaration::Declare(def) => {
constraint = exists_with_aliases(
aliases.clone(),
Vec::new(),
constrain_def(
&Env {
home,
rigids: ImMap::default(),
},
def,
constraint,
),
constrain_def(&env, def, constraint),
);
}
Declaration::DeclareRec(defs) => {
constraint = exists_with_aliases(
aliases.clone(),
Vec::new(),
constrain_recursive_defs(
&Env {
home,
rigids: ImMap::default(),
},
defs,
constraint,
),
constrain_recursive_defs(&env, defs, constraint),
);
}
Declaration::InvalidCycle(_, _) => panic!("TODO handle invalid cycle"),
Declaration::InvalidCycle(_, _) => {
// invalid cycles give a canonicalization error. we skip them here.
continue;
}
}
}