mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Distinguish between malformed ints and floats
This commit is contained in:
parent
9b3bb7abd7
commit
9f39153a35
3 changed files with 8 additions and 7 deletions
|
@ -58,7 +58,8 @@ pub enum Expr<'a> {
|
|||
|
||||
// Runtime errors
|
||||
MalformedStr(Box<[Loc<Problem>]>),
|
||||
MalformedNumber(Problem),
|
||||
MalformedInt(Problem),
|
||||
MalformedFloat(Problem),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue