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:
Ayaz Hafiz 2022-04-05 11:32:34 -04:00
parent 19c02aa087
commit 9fbc525d02
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
6 changed files with 22 additions and 13 deletions

View file

@ -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))