Skip to content

Binary float literals sometimes "work" #7878

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
huonw opened this issue Jul 18, 2013 · 2 comments
Closed

Binary float literals sometimes "work" #7878

huonw opened this issue Jul 18, 2013 · 2 comments
Labels
A-parser Area: The lexing & parsing of Rust source code to an AST

Comments

@huonw
Copy link
Member

huonw commented Jul 18, 2013

fn main() {
    let x = 0bf;
    let x = 0b101f;
}
bin-float.rs:2:8: 2:9 warning: unused variable: `x` [-W unused-variable (default)]
bin-float.rs:2     let x = 0bf;
                       ^
bin-float.rs:3:8: 3:9 warning: unused variable: `x` [-W unused-variable (default)]
bin-float.rs:3     let x = 0b101f;
                       ^
rustc: /home/huon/rust/src/llvm/lib/Support/APFloat.cpp:2491: llvm::APFloat::opStatus llvm::APFloat::convertFromString(llvm::StringRef, llvm::APFloat::roundingMode): Assertion `!str.empty() && "Invalid string length"' failed.

(The assertion is from the 0bf.)

Also:

compiler instead. Type :help for help.
rusti> 0bf
<anon>:15:0: 15:1 error: unresolved name `f`.
<anon>:15 f;
          ^

Either they should be fully supported, or not at all.

@huonw
Copy link
Member Author

huonw commented Sep 30, 2013

Triage: still an issue, the following even runs without failing:

fn main() { assert_eq!(0b101f, 101.0) }

i.e. they're not even being read as binary.

@alexcrichton
Copy link
Member

It looks like binary float literals were removed in 01cc9ec, and perhaps at some point later on we fixed rejecting these literals. Regardless, this is a real error now.

foo.rs:1:24: 1:32 error: binary float literal is not supported
foo.rs:1 fn main() { assert_eq!(0b101f64, 101.0) }
                                ^~~~~~~~

flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 4, 2021
new lint: string-slice

This is a restriction lint to highlight code that should have tests containing non-ascii characters. See rust-lang#6623.

changelog: new lint: [`string-slice`]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The lexing & parsing of Rust source code to an AST
Projects
None yet
Development

No branches or pull requests

2 participants