Skip to content

Commit

Permalink
Rollup merge of #40589 - topecongiro:floating-point-literal, r=nagisa
Browse files Browse the repository at this point in the history
Parse 0e+10 as a valid floating-point literal

Fixes issue #40408.
  • Loading branch information
Ariel Ben-Yehuda authored Mar 19, 2017
2 parents 5ffec58 + 8eaac08 commit d3e5a45
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ impl<'a> StringReader<'a> {
base = 16;
num_digits = self.scan_digits(16, 16);
}
'0'...'9' | '_' | '.' => {
'0'...'9' | '_' | '.' | 'e' | 'E' => {
num_digits = self.scan_digits(10, 10) + 1;
}
_ => {
Expand Down
16 changes: 16 additions & 0 deletions src/test/run-pass/issue-40408.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2017 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.

fn main() {
println!("{}", 0E+10);
println!("{}", 0e+10);
println!("{}", 00e+10);
println!("{}", 00E+10);
}

0 comments on commit d3e5a45

Please sign in to comment.