Change runtime assert to runtime error and debug assert (#6987)

This commit is contained in:
Jonathan Tran
2025-05-15 22:55:16 -04:00
committed by GitHub
parent a280a8c3f0
commit 23a0085c78

View File

@ -1277,7 +1277,15 @@ impl KclValue {
.satisfied(values.len(), allow_shrink)
.ok_or(CoercionError::from(self))?;
assert!(len <= values.len());
if len > values.len() {
let message = format!(
"Internal: Expected coerced array length {len} to be less than or equal to original length {}",
values.len()
);
exec_state.err(CompilationError::err(self.into(), message.clone()));
#[cfg(debug_assertions)]
panic!("{message}");
}
values.truncate(len);
Ok(KclValue::HomArray {