about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-02-07 00:14:14 -0800
committerbors <bors@rust-lang.org>2013-02-07 00:14:14 -0800
commitd9a61f2a1962c1ed0aaa2b7beac3a0daae40a162 (patch)
tree9461b5637fd4dd52dafe8f4bded09724b6f0ace6
parent951ad11d68521e3f99b73f5c1328cf8e3c98c943 (diff)
parent2600bcc05dcd51a5f6fe3404c60a5c1891a22dfe (diff)
downloadrust-d9a61f2a1962c1ed0aaa2b7beac3a0daae40a162.tar.gz
rust-d9a61f2a1962c1ed0aaa2b7beac3a0daae40a162.zip
auto merge of #4816 : lifthrasiir/rust/float-literal, r=graydon
See #4804 for details.
-rw-r--r--src/libsyntax/parse/lexer.rs7
-rw-r--r--src/test/compile-fail/no-binary-float-literal.rs17
-rw-r--r--src/test/compile-fail/no-hex-float-literal.rs17
3 files changed, 41 insertions, 0 deletions
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index 381183e736c..0f672d1de81 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -431,6 +431,13 @@ fn scan_number(c: char, rdr: string_reader) -> token::Token {
         let dec_part = scan_digits(rdr, 10u);
         num_str += ~"." + dec_part;
     }
+    if is_float {
+        match base {
+          16u => rdr.fatal(~"hexadecimal float literal is not supported"),
+          2u => rdr.fatal(~"binary float literal is not supported"),
+          _ => ()
+        }
+    }
     match scan_exponent(rdr) {
       Some(ref s) => {
         is_float = true;
diff --git a/src/test/compile-fail/no-binary-float-literal.rs b/src/test/compile-fail/no-binary-float-literal.rs
new file mode 100644
index 00000000000..0fa61b1af52
--- /dev/null
+++ b/src/test/compile-fail/no-binary-float-literal.rs
@@ -0,0 +1,17 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// error-pattern:binary float literal is not supported
+
+fn main() {
+    0b101010f;
+    0b101.010;
+    0b101p4f;
+}
diff --git a/src/test/compile-fail/no-hex-float-literal.rs b/src/test/compile-fail/no-hex-float-literal.rs
new file mode 100644
index 00000000000..4abb6093b24
--- /dev/null
+++ b/src/test/compile-fail/no-hex-float-literal.rs
@@ -0,0 +1,17 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// error-pattern:hexadecimal float literal is not supported
+
+fn main() {
+    0xABC.Df;
+    0x567.89;
+    0xDEAD.BEEFp-2f;
+}