Distinguish between malformed ints and floats

This commit is contained in:
Richard Feldman 2019-09-14 16:38:44 -05:00
parent 9b3bb7abd7
commit 9f39153a35
3 changed files with 8 additions and 7 deletions

View file

@ -58,7 +58,8 @@ pub enum Expr<'a> {
// Runtime errors
MalformedStr(Box<[Loc<Problem>]>),
MalformedNumber(Problem),
MalformedInt(Problem),
MalformedFloat(Problem),
}
#[derive(Clone, Debug, PartialEq)]

View file

@ -111,12 +111,12 @@ where
match f64_buf.parse::<f64>() {
Ok(float) if float.is_finite() => Expr::Float(float),
_ => Expr::MalformedNumber(Problem::OutsideSupportedRange),
_ => Expr::MalformedFloat(Problem::OutsideSupportedRange),
}
} else {
match before_decimal.parse::<i64>() {
Ok(int_val) => Expr::Int(int_val),
Err(_) => Expr::MalformedNumber(Problem::OutsideSupportedRange),
Err(_) => Expr::MalformedInt(Problem::OutsideSupportedRange),
}
};