Turn a non-finite GSC number into a script error, not a panic, when it meets text

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bulat Fatykh
2026-10-01 01:28:56 +03:00
parent 11514ea37d
commit 0484c02517
+3 -2
View File
@@ -369,8 +369,9 @@ fn format_g(value: f64) -> String {
pub(super) fn to_text(value: &Value) -> Option<String> {
match value {
Value::Int(n) => Some(n.to_string()),
Value::Float(n) => Some(format_g(f64::from(*n))),
Value::Vector(v) => Some(format!(
// format_g needs the exponent that NaN and infinity print without.
Value::Float(n) if n.is_finite() => Some(format_g(f64::from(*n))),
Value::Vector(v) if v.iter().all(|n| n.is_finite()) => Some(format!(
"({}, {}, {})",
format_g(f64::from(v[0])),
format_g(f64::from(v[1])),