mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
constrain expects in the right order
This commit is contained in:
parent
c2206f3e4d
commit
b6f1fd6f40
1 changed files with 14 additions and 6 deletions
|
@ -1357,8 +1357,22 @@ pub(crate) fn sort_can_defs_new(
|
||||||
// TODO: inefficient, but I want to make this what CanDefs contains in the future
|
// TODO: inefficient, but I want to make this what CanDefs contains in the future
|
||||||
let mut defs: Vec<_> = defs.into_iter().map(|x| x.unwrap()).collect();
|
let mut defs: Vec<_> = defs.into_iter().map(|x| x.unwrap()).collect();
|
||||||
|
|
||||||
|
// symbols are put in declarations in dependency order, from "main" up, so
|
||||||
|
//
|
||||||
|
// x = 3
|
||||||
|
// y = x + 1
|
||||||
|
//
|
||||||
|
// will get ordering [ y, x ]
|
||||||
let mut declarations = Declarations::with_capacity(defs.len());
|
let mut declarations = Declarations::with_capacity(defs.len());
|
||||||
|
|
||||||
|
// because of the ordering of declarations, expects should come first because they are
|
||||||
|
// independent, but can rely on all other top-level symbols in the module
|
||||||
|
for (condition, region) in expects.conditions.into_iter().zip(expects.regions) {
|
||||||
|
// an `expect` does not have a user-defined name, but we'll need a name to call the expectation
|
||||||
|
let name = scope.gen_unique_symbol();
|
||||||
|
declarations.push_expect(name, Loc::at(region, condition));
|
||||||
|
}
|
||||||
|
|
||||||
for (symbol, alias) in aliases.into_iter() {
|
for (symbol, alias) in aliases.into_iter() {
|
||||||
output.aliases.insert(symbol, alias);
|
output.aliases.insert(symbol, alias);
|
||||||
}
|
}
|
||||||
|
@ -1523,12 +1537,6 @@ pub(crate) fn sort_can_defs_new(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (condition, region) in expects.conditions.into_iter().zip(expects.regions) {
|
|
||||||
// an `expect` does not have a user-defined name, but we'll need a name to call the expectation
|
|
||||||
let name = scope.gen_unique_symbol();
|
|
||||||
declarations.push_expect(name, Loc::at(region, condition));
|
|
||||||
}
|
|
||||||
|
|
||||||
(declarations, output)
|
(declarations, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue