Skip to content

Commit 4accdd0

Browse files
committed
fix(evaluator): wrap TLA evaluation in state
1 parent ee1b2e4 commit 4accdd0

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

  • crates/jrsonnet-evaluator/src

crates/jrsonnet-evaluator/src/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,15 @@ impl EvaluationState {
330330

331331
/// If passed value is function then call with set TLA
332332
pub fn with_tla(&self, val: Val) -> Result<Val> {
333-
Ok(match val {
334-
Val::Func(func) => func.evaluate_map(
335-
self.create_default_context()?,
336-
&self.settings().tla_vars,
337-
true,
338-
)?,
339-
v => v,
333+
self.run_in_state(|| {
334+
Ok(match val {
335+
Val::Func(func) => func.evaluate_map(
336+
self.create_default_context()?,
337+
&self.settings().tla_vars,
338+
true,
339+
)?,
340+
v => v,
341+
})
340342
})
341343
}
342344
}
@@ -408,7 +410,7 @@ impl EvaluationState {
408410
pub fn add_tla_code(&self, name: Rc<str>, code: Rc<str>) -> Result<()> {
409411
let value =
410412
self.evaluate_snippet_raw(Rc::new(PathBuf::from(format!("tla_code {}", name))), code)?;
411-
self.add_ext_var(name, value);
413+
self.add_tla(name, value);
412414
Ok(())
413415
}
414416

0 commit comments

Comments
 (0)