Skip to content

Commit

Permalink
Merge pull request #253 from dtolnay/lit
Browse files Browse the repository at this point in the history
Reject duplicate sign in float literal
  • Loading branch information
dtolnay committed Sep 25, 2020
2 parents ac910cf + 88ad48d commit e45143b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,15 +591,20 @@ fn float_digits(input: Cursor) -> Result<Cursor, LexError> {
}

if has_exp {
let mut has_sign = false;
let mut has_exp_value = false;
while let Some(&ch) = chars.peek() {
match ch {
'+' | '-' => {
if has_exp_value {
break;
}
if has_sign {
return Err(LexError);
}
chars.next();
len += 1;
has_sign = true;
}
'0'..='9' => {
chars.next();
Expand Down
1 change: 1 addition & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ fn literal_suffix() {
assert_eq!(token_count("b'b'b"), 1);
assert_eq!(token_count("0E"), 1);
assert_eq!(token_count("0o0A"), 1);
assert_eq!(token_count("0E--0"), 4);
}

#[test]
Expand Down

0 comments on commit e45143b

Please sign in to comment.