mirror of
https://github.com/typst/typst
synced 2025-05-16 01:55:28 +08:00
Print the string that is not castable to number (#1207)
This commit is contained in:
parent
e32c6f8e8a
commit
84b9d9c990
@ -38,7 +38,7 @@ cast_from_value! {
|
|||||||
v: bool => Self(v as i64),
|
v: bool => Self(v as i64),
|
||||||
v: i64 => Self(v),
|
v: i64 => Self(v),
|
||||||
v: f64 => Self(v as i64),
|
v: f64 => Self(v as i64),
|
||||||
v: EcoString => Self(v.parse().map_err(|_| "not a valid integer")?),
|
v: EcoString => Self(v.parse().map_err(|_| eco_format!("invalid integer: {}", v))?),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a value to a float.
|
/// Convert a value to a float.
|
||||||
@ -79,7 +79,7 @@ cast_from_value! {
|
|||||||
v: i64 => Self(v as f64),
|
v: i64 => Self(v as f64),
|
||||||
v: f64 => Self(v),
|
v: f64 => Self(v),
|
||||||
v: Ratio => Self(v.get()),
|
v: Ratio => Self(v.get()),
|
||||||
v: EcoString => Self(v.parse().map_err(|_| "not a valid float")?),
|
v: EcoString => Self(v.parse().map_err(|_| eco_format!("invalid float: {}", v))?),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a grayscale color.
|
/// Create a grayscale color.
|
||||||
|
@ -26,11 +26,11 @@
|
|||||||
#float(float)
|
#float(float)
|
||||||
|
|
||||||
---
|
---
|
||||||
// Error: 6-12 not a valid integer
|
// Error: 6-12 invalid integer: nope
|
||||||
#int("nope")
|
#int("nope")
|
||||||
|
|
||||||
---
|
---
|
||||||
// Error: 8-15 not a valid float
|
// Error: 8-15 invalid float: 1.2.3
|
||||||
#float("1.2.3")
|
#float("1.2.3")
|
||||||
|
|
||||||
---
|
---
|
||||||
|
Loading…
x
Reference in New Issue
Block a user