mirror of
https://github.com/typst/typst
synced 2025-08-11 21:57:55 +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"
|
"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
|
SyntaxKind::Int
|
||||||
} else if base == 10 && number.parse::<f64>().is_ok() {
|
} else if base == 10 && number2.parse::<f64>().is_ok() {
|
||||||
SyntaxKind::Float
|
SyntaxKind::Float
|
||||||
} else {
|
} else {
|
||||||
return self.error(match base {
|
return self.error(match base {
|
||||||
|
@ -7,10 +7,14 @@
|
|||||||
--- int-base-binary-invalid ---
|
--- int-base-binary-invalid ---
|
||||||
// Error: 2-7 invalid binary number: 0b123
|
// Error: 2-7 invalid binary number: 0b123
|
||||||
#0b123
|
#0b123
|
||||||
|
// Error: 2-8 invalid binary number: 0b1_23
|
||||||
|
#0b1_23
|
||||||
|
|
||||||
--- int-base-hex-invalid ---
|
--- int-base-hex-invalid ---
|
||||||
// Error: 2-8 invalid hexadecimal number: 0x123z
|
// Error: 2-8 invalid hexadecimal number: 0x123z
|
||||||
#0x123z
|
#0x123z
|
||||||
|
// Error: 2-9 invalid hexadecimal number: 0x12_3z
|
||||||
|
#0x12_3z
|
||||||
|
|
||||||
--- int-constructor ---
|
--- int-constructor ---
|
||||||
// Test conversion to numbers.
|
// Test conversion to numbers.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user