mirror of
https://github.com/typst/typst
synced 2025-08-12 06:07:54 +08:00
Show original numeric literal in error message
This commit is contained in:
parent
16ce9c1665
commit
e8a724f8ee
@ -862,11 +862,11 @@ impl Lexer<'_> {
|
||||
"number literals may not start or end with an underscore"
|
||||
));
|
||||
}
|
||||
let number = ignore_underscores(number);
|
||||
let number2 = ignore_underscores(number);
|
||||
|
||||
let kind = if i64::from_str_radix(&number, base).is_ok() {
|
||||
let kind = if i64::from_str_radix(&number2, base).is_ok() {
|
||||
SyntaxKind::Int
|
||||
} else if base == 10 && number.parse::<f64>().is_ok() {
|
||||
} else if base == 10 && number2.parse::<f64>().is_ok() {
|
||||
SyntaxKind::Float
|
||||
} else {
|
||||
return self.error(match base {
|
||||
|
@ -7,10 +7,14 @@
|
||||
--- int-base-binary-invalid ---
|
||||
// Error: 2-7 invalid binary number: 0b123
|
||||
#0b123
|
||||
// Error: 2-8 invalid binary number: 0b1_23
|
||||
#0b1_23
|
||||
|
||||
--- int-base-hex-invalid ---
|
||||
// Error: 2-8 invalid hexadecimal number: 0x123z
|
||||
#0x123z
|
||||
// Error: 2-9 invalid hexadecimal number: 0x12_3z
|
||||
#0x12_3z
|
||||
|
||||
--- int-constructor ---
|
||||
// Test conversion to numbers.
|
||||
|
Loading…
x
Reference in New Issue
Block a user