Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

Use external float parser rather than rustc's #148

Merged
merged 1 commit into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libslide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ required-features = ["benchmark-internals"]

[dependencies]
rug = "1.9.0"
strtod = "0.0.1"

[dependencies.num-traits]
version = "0.2"
Expand Down
5 changes: 4 additions & 1 deletion libslide/src/scanner.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod types;

use crate::diagnostics::Diagnostic;
use strtod::strtod;
use types::TokenType as TT;
pub use types::*;

Expand Down Expand Up @@ -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::<f64>().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)));
}
Expand Down
Binary file not shown.
14 changes: 14 additions & 0 deletions slide/src/test/ui/giant_float.slide
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
===in
000000000.0055555555555555555555000005555555555555555555455555555555555555555555555555555555555555550000005555555555555555555555555555555455555555555555555555555555555555555555555555550000004
===in

~~~stdout
0.005555555555555556
~~~stdout

~~~stderr
~~~stderr

~~~exitcode
0
~~~exitcode