Skip to content

Commit aed2194

Browse files
chapter17: fix parse_number 0
1 parent c1375f8 commit aed2194

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/sea_of_nodes/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1811,7 +1811,7 @@ impl<'a> Lexer<'a> {
18111811
fn parse_number<'t>(&mut self, types: &Types<'t>) -> PResult<Ty<'t>> {
18121812
let (flt, snum) = self.is_long_or_double();
18131813
if !flt {
1814-
if snum.chars().next() == Some('0') {
1814+
if snum.len() > 1 && snum.chars().next() == Some('0') {
18151815
Err("Syntax error: integer values cannot start with '0'".to_string())
18161816
} else {
18171817
snum.parse().map(|i| *types.get_int(i)).map_err(|_| {

0 commit comments

Comments
 (0)