Refactor ParseProblem

* Remove the `pos` field, which was always being assigned Position::default()
* Remove one use of this `pos`, by removing the never-used SyntaxError::ConditionFailed variant
* Adjust the other use to do what was probably intended - which is to say, pointing to the beginning of the def with the error
* Rename to FileError, reuse `SourceError` as an inner field, to avoid duplicating the `bytes`
This commit is contained in:
Joshua Warner 2022-01-03 19:52:33 -08:00
parent 226237d1cd
commit f22f96843e
9 changed files with 53 additions and 66 deletions

View file

@ -8,6 +8,7 @@ use crate::state::State;
use bumpalo::collections::Vec as BumpVec;
use bumpalo::Bump;
use roc_region::all::Loc;
use roc_region::all::Position;
pub fn parse_expr_with<'a>(
arena: &'a Bump,
@ -27,7 +28,7 @@ pub fn parse_loc_with<'a>(
match crate::expr::test_parse_expr(0, arena, state.clone()) {
Ok(loc_expr) => Ok(loc_expr),
Err(fail) => Err(SyntaxError::Expr(fail).into_source_error(&state)),
Err(fail) => Err(SyntaxError::Expr(fail, Position::default()).into_source_error(&state)),
}
}