diff --git a/libslide/Cargo.toml b/libslide/Cargo.toml index 1f4e4fbdc..deaf5f108 100644 --- a/libslide/Cargo.toml +++ b/libslide/Cargo.toml @@ -26,6 +26,7 @@ required-features = ["benchmark-internals"] [dependencies] rug = "1.9.0" +strtod = "0.0.1" [dependencies.num-traits] version = "0.2" diff --git a/libslide/src/scanner.rs b/libslide/src/scanner.rs index f1ce918d5..a02b4523a 100644 --- a/libslide/src/scanner.rs +++ b/libslide/src/scanner.rs @@ -1,6 +1,7 @@ pub mod types; use crate::diagnostics::Diagnostic; +use strtod::strtod; use types::TokenType as TT; pub use types::*; @@ -123,7 +124,9 @@ impl Scanner { float_str.push(*self.next().unwrap()); float_str.push_str(&self.collect_while(|c| c.is_digit(10))); } - let float = float_str.parse::().unwrap(); + // TODO(https://github.com/rust-lang/rust/issues/31407): rustc's float parser may drop some + // valid float literals. For now, use an external parser. + let float = strtod(&float_str).unwrap(); self.output.push(tok!(TT::Float(float), (start, self.pos))); } diff --git a/slide/fuzz/seed/MTEAGjAwMDAwMDAwLjAwMDAxMQAaMDAwMDAwMDAuMDAwMDAwMDA0ABowMDAwMDAwMC4wMDAwMDAwMDAwMDA0ABowMDAwMDAwMC4wMDU1NTU1NTU1NTU1NTU1NTU1NT b/slide/fuzz/seed/MTEAGjAwMDAwMDAwLjAwMDAxMQAaMDAwMDAwMDAuMDAwMDAwMDA0ABowMDAwMDAwMC4wMDAwMDAwMDAwMDA0ABowMDAwMDAwMC4wMDU1NTU1NTU1NTU1NTU1NTU1NT new file mode 100644 index 000000000..c03c5f986 Binary files /dev/null and b/slide/fuzz/seed/MTEAGjAwMDAwMDAwLjAwMDAxMQAaMDAwMDAwMDAuMDAwMDAwMDA0ABowMDAwMDAwMC4wMDAwMDAwMDAwMDA0ABowMDAwMDAwMC4wMDU1NTU1NTU1NTU1NTU1NTU1NT differ diff --git a/slide/src/test/ui/giant_float.slide b/slide/src/test/ui/giant_float.slide new file mode 100644 index 000000000..af8db5ac9 --- /dev/null +++ b/slide/src/test/ui/giant_float.slide @@ -0,0 +1,14 @@ +===in +000000000.0055555555555555555555000005555555555555555555455555555555555555555555555555555555555555550000005555555555555555555555555555555455555555555555555555555555555555555555555555550000004 +===in + +~~~stdout +0.005555555555555556 +~~~stdout + +~~~stderr +~~~stderr + +~~~exitcode +0 +~~~exitcode