Skip to content

Commit 3e2e5cb

Browse files
committed
Handling leading zeros in integer literals
1 parent 77baa1f commit 3e2e5cb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/lpython/parser/tokenizer.re

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ void lex_int(Allocator &al, const unsigned char *s,
9696
u.from_smallint(n);
9797
} else {
9898
lex_dec_int_large(al, s, e, u);
99+
if (s[0] == '0' && u.n != 0) {
100+
throw parser_local::TokenizerError(
101+
"Leading zeros in decimal integer are not allowed", {loc});
102+
}
99103
}
100104
return;
101105
}

0 commit comments

Comments
 (0)