diff --git a/compiler/literal/src/float.rs b/compiler/literal/src/float.rs index 49771b8184..3764323de3 100644 --- a/compiler/literal/src/float.rs +++ b/compiler/literal/src/float.rs @@ -55,6 +55,7 @@ pub fn format_fixed(precision: usize, magnitude: f64, case: Case, alternate_form match magnitude { magnitude if magnitude.is_finite() => { let point = decimal_point_or_empty(precision, alternate_form); + let precision = std::cmp::min(precision, u16::MAX as usize); format!("{magnitude:.precision$}{point}") } magnitude if magnitude.is_nan() => format_nan(case), diff --git a/vm/src/stdlib/io.rs b/vm/src/stdlib/io.rs index 3e1979e3d0..e4339ae61a 100644 --- a/vm/src/stdlib/io.rs +++ b/vm/src/stdlib/io.rs @@ -259,6 +259,9 @@ mod _io { } fn write(&mut self, data: &[u8]) -> Option { + if data.is_empty() { + return Some(0); + } let length = data.len(); self.cursor.write_all(data).ok()?; Some(length as u64)