Skip to content

Parsing "+" or "-" to f32/f64 on nightly #29042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yoeljacobsen opened this issue Oct 14, 2015 · 3 comments
Closed

Parsing "+" or "-" to f32/f64 on nightly #29042

yoeljacobsen opened this issue Oct 14, 2015 · 3 comments
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta.

Comments

@yoeljacobsen
Copy link

I tried this code:

match "+".parse::<f32>() {
  Ok(v) => println!("f32 OK: {}", v),
  Err(e) => println!("f32 Error: {}", e) 
}

match "-".parse::<f64>() {
  Ok(v) => println!("f64 OK: {}", v),
  Err(e) => println!("f64 Error: {}", e) 
}

I expected to see this happen: "Error: invalid float literal"

Instead, this happened: OK: 0

It seems the "leading +" and "leading -" is broken.

Further, with i32 and i64 is emits an error but IMO an incorrect one:

"cannot parse integer from empty string"

I would expect: "Invalid integer literal"

Meta

rustc --version --verbose:

rustc 1.5.0-nightly (81b3b27 2015-10-11)
binary: rustc
commit-hash: 81b3b27
commit-date: 2015-10-11
host: x86_64-unknown-linux-gnu
release: 1.5.0-nightly

@hanna-kruppe
Copy link
Contributor

Oh my, the float part is embarrassing. Preparing a fix right now.

@alexcrichton alexcrichton added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Oct 14, 2015
@alexcrichton
Copy link
Member

Thanks for taking a look @rkruppe! Looks like this is working as expected on stable and has leaked into beta/nightly, so tagging as such.

@hanna-kruppe
Copy link
Contributor

Yes, this is a bug (not checking for empty strings in the right places) of the dec2flt code. The bug is also in beta, so the PR (which I'll file very soon) should probably be backported to beta.

hanna-kruppe pushed a commit to hanna-kruppe/rust that referenced this issue Oct 14, 2015
brson pushed a commit to brson/rust that referenced this issue Oct 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Projects
None yet
Development

No branches or pull requests

3 participants