mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
some work on expect comment regions
This commit is contained in:
parent
7597d11b59
commit
5a93da5a11
3 changed files with 20 additions and 4 deletions
|
@ -1367,10 +1367,17 @@ pub(crate) fn sort_can_defs_new(
|
|||
|
||||
// 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) {
|
||||
let it = expects
|
||||
.conditions
|
||||
.into_iter()
|
||||
.zip(expects.regions)
|
||||
.zip(expects.preceding_comment);
|
||||
|
||||
for ((condition, region), preceding_comment) in it {
|
||||
// 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.push_expect(preceding_comment, name, Loc::at(region, condition));
|
||||
}
|
||||
|
||||
for (symbol, alias) in aliases.into_iter() {
|
||||
|
|
|
@ -2190,12 +2190,17 @@ impl Declarations {
|
|||
index
|
||||
}
|
||||
|
||||
pub fn push_expect(&mut self, name: Symbol, loc_expr: Loc<Expr>) -> usize {
|
||||
pub fn push_expect(
|
||||
&mut self,
|
||||
preceding_comment: Region,
|
||||
name: Symbol,
|
||||
loc_expr: Loc<Expr>,
|
||||
) -> usize {
|
||||
let index = self.declarations.len();
|
||||
|
||||
self.declarations.push(DeclarationTag::Expectation);
|
||||
self.variables.push(Variable::BOOL);
|
||||
self.symbols.push(Loc::at_zero(name));
|
||||
self.symbols.push(Loc::at(preceding_comment, name));
|
||||
self.annotations.push(None);
|
||||
|
||||
self.expressions.push(loc_expr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue