mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
Fix: crash with invalid decimal literal in expo
This commit is contained in:
parent
e0f0f0ee9e
commit
db3adec34d
1 changed files with 22 additions and 7 deletions
|
@ -461,6 +461,7 @@ impl Lexer /*<'a>*/ {
|
||||||
let mut num = mantissa;
|
let mut num = mantissa;
|
||||||
debug_power_assert!(self.peek_cur_ch(), ==, Some('e'));
|
debug_power_assert!(self.peek_cur_ch(), ==, Some('e'));
|
||||||
num.push(self.consume().unwrap()); // e
|
num.push(self.consume().unwrap()); // e
|
||||||
|
if self.peek_cur_ch().is_some() {
|
||||||
num.push(self.consume().unwrap()); // + | -
|
num.push(self.consume().unwrap()); // + | -
|
||||||
while let Some(cur) = self.peek_cur_ch() {
|
while let Some(cur) = self.peek_cur_ch() {
|
||||||
if cur.is_ascii_digit() || cur == '_' {
|
if cur.is_ascii_digit() || cur == '_' {
|
||||||
|
@ -470,6 +471,20 @@ impl Lexer /*<'a>*/ {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(self.emit_token(RatioLit, &num))
|
Ok(self.emit_token(RatioLit, &num))
|
||||||
|
} else {
|
||||||
|
let token = self.emit_token(RatioLit, &num);
|
||||||
|
Err(LexError::syntax_error(
|
||||||
|
0,
|
||||||
|
token.loc(),
|
||||||
|
switch_lang!(
|
||||||
|
"japanese" => format!("`{}`は無効な十進数リテラルです", &token.content),
|
||||||
|
"simplified_chinese" => format!("`{}`是无效的十进制字词", &token.content),
|
||||||
|
"traditional_chinese" => format!("`{}`是無效的十進製文字", &token.content),
|
||||||
|
"english" => format!("`{}` is invalid decimal literal", &token.content),
|
||||||
|
),
|
||||||
|
None,
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `_` will be removed at compiletime
|
/// `_` will be removed at compiletime
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue