difftreelog
fix lazy object comprehension
in: master
2 files changed
cmds/jrsonnet/Cargo.tomldiffbeforeafterboth15 "exp-object-iteration",15 "exp-object-iteration",16 "exp-bigint",16 "exp-bigint",17 "exp-apply",17 "exp-apply",18 "exp-regex",18]19]19# Use mimalloc as allocator20# Use mimalloc as allocator20mimalloc = ["mimallocator"]21mimalloc = ["mimallocator"]crates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/evaluate/mod.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/mod.rs
@@ -596,10 +596,24 @@
ArrComp(expr, comp_specs) => {
let mut out = Vec::new();
evaluate_comp(ctx, comp_specs, &mut |ctx| {
- out.push(evaluate(ctx, expr)?);
+ #[derive(Trace)]
+ struct EvaluateThunk {
+ ctx: Context,
+ expr: LocExpr,
+ }
+ impl ThunkValue for EvaluateThunk {
+ type Output = Val;
+ fn get(self: Box<Self>) -> Result<Val> {
+ evaluate(self.ctx, &self.expr)
+ }
+ }
+ out.push(Thunk::new(EvaluateThunk {
+ ctx,
+ expr: expr.clone(),
+ }));
Ok(())
})?;
- Val::Arr(ArrValue::eager(out))
+ Val::Arr(ArrValue::lazy(out))
}
Obj(body) => Val::Obj(evaluate_object(ctx, body)?),
ObjExtend(a, b) => evaluate_add_op(