git.delta.rocks / jrsonnet / refs/commits / 09336b18552d

difftreelog

fix(evaluator) use context with globals for `into_json`

Лач2020-06-25parent: #99ccb50.patch.diff
in: master

1 file changed

modifiedcrates/jsonnet-evaluator/src/val.rsdiffbeforeafterboth
174 })174 })
175 }175 }
176 pub fn into_json(self, padding: usize) -> Result<String> {176 pub fn into_json(self, padding: usize) -> Result<String> {
177 let ctx = Context::new().with_var("__tmp__to_json__".to_owned(), self)?;177 with_state(|s| {
178 let ctx = s
179 .create_default_context()?
180 .with_var("__tmp__to_json__".to_owned(), self)?;
178 if let Val::Str(result) = evaluate(181 if let Val::Str(result) = evaluate(
179 ctx,182 &ctx,
180 &el!(Expr::Apply(183 &el!(Expr::Apply(
181 el!(Expr::Index(184 el!(Expr::Index(
182 el!(Expr::Var("std".to_owned())),185 el!(Expr::Var("std".to_owned())),
193 } else {196 } else {
194 unreachable!()197 unreachable!()
195 }198 }
199 })
196 }200 }
197}201}
198202