--- a/crates/jrsonnet-stdlib/src/manifest/toml.rs +++ b/crates/jrsonnet-stdlib/src/manifest/toml.rs @@ -1,9 +1,7 @@ use std::borrow::Cow; use jrsonnet_evaluator::{ - IStr, ObjValue, Result, ResultExt, Val, bail, in_description_frame, - manifest::{ManifestFormat, escape_string_json_buf}, - val::ArrValue, + Error, IStr, ObjValue, Result, ResultExt, Val, bail, ensure_sufficient_stack, in_description_frame, manifest::{ManifestFormat, escape_string_json_buf}, val::ArrValue }; pub struct TomlFormat<'s> { @@ -104,7 +102,7 @@ Val::Num(n) => write!(buf, "{n}").unwrap(), #[cfg(feature = "exp-bigint")] Val::BigInt(n) => write!(buf, "{n}").unwrap(), - Val::Arr(a) => { + Val::Arr(a) => ensure_sufficient_stack(|| { buf.push('['); let mut had_items = false; @@ -137,8 +135,9 @@ buf.push_str(cur_padding); } buf.push(']'); - } - Val::Obj(o) => { + Ok::<_, Error>(()) + })?, + Val::Obj(o) => ensure_sufficient_stack(|| { o.run_assertions()?; buf.push('{'); @@ -171,7 +170,8 @@ } buf.push('}'); - } + Ok::<_, Error>(()) + })?, Val::Null => { bail!("tried to manifest null") } @@ -218,14 +218,14 @@ } first = false; path.push(k.clone()); - in_description_frame( + ensure_sufficient_stack(|| in_description_frame( || format!("section <{k}> manifestification"), || match v { Val::Obj(obj) => manifest_table(&obj, path, buf, cur_padding, options), Val::Arr(arr) => manifest_table_array(&arr, path, buf, cur_padding, options), _ => unreachable!("iterating over sections"), }, - )?; + ))?; path.pop(); } Ok(())