mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
Make sure float suffixes are parsed out after can
Before we hit mono, we need to make sure the suffixes of numeric literals are parsed out from the literal string, so that we don't try to parse something whose type we already know but has the extraneous suffix. Co'ed with @tagraves
This commit is contained in:
parent
19c02aa087
commit
9fbc525d02
6 changed files with 22 additions and 13 deletions
|
@ -144,7 +144,7 @@ pub fn finish_parsing_base(
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn finish_parsing_float(raw: &str) -> Result<(f64, FloatBound), (&str, FloatErrorKind)> {
|
||||
pub fn finish_parsing_float(raw: &str) -> Result<(&str, f64, FloatBound), (&str, FloatErrorKind)> {
|
||||
let (opt_bound, raw_without_suffix) = parse_literal_suffix(raw);
|
||||
|
||||
let bound = match opt_bound {
|
||||
|
@ -155,7 +155,7 @@ pub fn finish_parsing_float(raw: &str) -> Result<(f64, FloatBound), (&str, Float
|
|||
|
||||
// Ignore underscores.
|
||||
match raw_without_suffix.replace('_', "").parse::<f64>() {
|
||||
Ok(float) if float.is_finite() => Ok((float, bound)),
|
||||
Ok(float) if float.is_finite() => Ok((raw_without_suffix, float, bound)),
|
||||
Ok(float) => {
|
||||
if float.is_sign_positive() {
|
||||
Err((raw, FloatErrorKind::PositiveInfinity))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue