Evaluate REMINDs

This commit is contained in:
Joscha 2021-12-21 00:14:14 +01:00
parent fe22c66c5c
commit 66da16f4e3
6 changed files with 115 additions and 29 deletions

View file

@ -34,6 +34,16 @@ pub enum Error {
from: NaiveDate,
to: NaiveDate,
},
/// A `REMIND`'s delta did not move backwards in time from the entry's start
/// date. Instead, it either remained at the start date (`to == from`) or
/// moved forwards in time (`from < to`).
#[error("remind delta did not move backwards")]
RemindDidNotMoveBackwards {
index: usize,
span: Span,
from: NaiveDate,
to: NaiveDate,
},
/// A `MOVE a TO b` statement was executed, but there was no entry at the
/// date `a`.
#[error("tried to move nonexisting entry")]
@ -135,6 +145,19 @@ impl Error {
);
Self::print_at(sources, index, span, msg);
}
Error::RemindDidNotMoveBackwards {
index,
span,
from,
to,
} => {
let msg = format!(
"Remind delta did not move backwards\
\nMoved from {} to {}",
from, to
);
Self::print_at(sources, index, span, msg);
}
Error::MoveWithoutSource { index, span } => {
let msg = "Tried to move nonexisting entry".to_string();
Self::print_at(sources, index, span, msg);