Skip to content

Commit d9a61f2

Browse files
committed
auto merge of #4816 : lifthrasiir/rust/float-literal, r=graydon
See #4804 for details.
2 parents 951ad11 + 2600bcc commit d9a61f2

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

src/libsyntax/parse/lexer.rs

+7
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,13 @@ fn scan_number(c: char, rdr: string_reader) -> token::Token {
431431
let dec_part = scan_digits(rdr, 10u);
432432
num_str += ~"." + dec_part;
433433
}
434+
if is_float {
435+
match base {
436+
16u => rdr.fatal(~"hexadecimal float literal is not supported"),
437+
2u => rdr.fatal(~"binary float literal is not supported"),
438+
_ => ()
439+
}
440+
}
434441
match scan_exponent(rdr) {
435442
Some(ref s) => {
436443
is_float = true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern:binary float literal is not supported
12+
13+
fn main() {
14+
0b101010f;
15+
0b101.010;
16+
0b101p4f;
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern:hexadecimal float literal is not supported
12+
13+
fn main() {
14+
0xABC.Df;
15+
0x567.89;
16+
0xDEAD.BEEFp-2f;
17+
}

0 commit comments

Comments
 (0)