mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-24 06:55:15 +00:00
parse the region of the preceding comment for an expect
This commit is contained in:
parent
35733d51dc
commit
7597d11b59
8 changed files with 35 additions and 11 deletions
|
@ -331,7 +331,10 @@ pub enum ValueDef<'a> {
|
|||
body_expr: &'a Loc<Expr<'a>>,
|
||||
},
|
||||
|
||||
Expect(&'a Loc<Expr<'a>>),
|
||||
Expect {
|
||||
condition: &'a Loc<Expr<'a>>,
|
||||
preceding_comment: Region,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
|
|
|
@ -584,6 +584,7 @@ fn parse_defs_end<'a>(
|
|||
let initial = state.clone();
|
||||
|
||||
let mut spaces_before_current = &[] as &[_];
|
||||
let spaces_before_current_start = state.pos();
|
||||
|
||||
let state = match space0_e(min_indent, EExpr::IndentStart).parse(arena, state) {
|
||||
Err((MadeProgress, _, s)) => {
|
||||
|
@ -625,7 +626,12 @@ fn parse_defs_end<'a>(
|
|||
let end = loc_def_expr.region.end();
|
||||
let region = Region::new(start, end);
|
||||
|
||||
let value_def = ValueDef::Expect(arena.alloc(loc_def_expr));
|
||||
let preceding_comment = Region::new(spaces_before_current_start, start);
|
||||
|
||||
let value_def = ValueDef::Expect {
|
||||
condition: arena.alloc(loc_def_expr),
|
||||
preceding_comment,
|
||||
};
|
||||
defs.push_value_def(value_def, region, spaces_before_current, &[]);
|
||||
|
||||
global_state = state;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue