git.delta.rocks / jrsonnet / refs/commits / 2e6febe0ffcd

difftreelog

fix(evaluator) indirect_self bug

Лач2020-05-30parent: #abae2f2.patch.diff
in: master

4 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,9 +1,16 @@
 # This file is automatically @generated by Cargo.
 # It is not intended for manual editing.
 [[package]]
+name = "closure"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6173fd61b610d15a7566dd7b7620775627441c4ab9dac8906e17cb93a24b782"
+
+[[package]]
 name = "jsonnet-evaluator"
 version = "0.1.0"
 dependencies = [
+ "closure",
  "jsonnet-parser",
  "jsonnet-stdlib",
 ]
modifiedcrates/jsonnet-evaluator/src/ctx.rsdiffbeforeafterboth
--- a/crates/jsonnet-evaluator/src/ctx.rs
+++ b/crates/jsonnet-evaluator/src/ctx.rs
@@ -74,7 +74,6 @@
 		new_this: Option<ObjValue>,
 		new_super_obj: Option<ObjValue>,
 	) -> Context {
-		println!("Extend with {:?} {:?}", new_dollar, new_this);
 		let dollar = new_dollar.or_else(|| self.0.dollar.clone());
 		let this = new_this.or_else(|| self.0.this.clone());
 		let super_obj = new_super_obj.or_else(|| self.0.super_obj.clone());
modifiedcrates/jsonnet-evaluator/src/evaluate.rsdiffbeforeafterboth
before · crates/jsonnet-evaluator/src/evaluate.rs
1use crate::{2	binding, bool_val, context_creator, function_default, function_rhs, future_wrapper, lazy_val,3	Binding, Context, ContextCreator, FuncDesc, ObjMember, ObjValue, Val,4};5use closure::closure;6use jsonnet_parser::{7	ArgsDesc, BinaryOpType, BindSpec, Expr, FieldMember, LiteralType, Member, ObjBody, ParamsDesc,8	UnaryOpType, Visibility,9};10use std::{11	collections::{BTreeMap, HashMap},12	rc::Rc,13};1415pub fn evaluate_binding(b: &BindSpec, context_creator: ContextCreator) -> (String, Binding) {16	let b = b.clone();17	if let Some(args) = &b.params {18		let args = args.clone();19		(20			b.name.clone(),21			binding!(move |this, super_obj| Val::Lazy(lazy_val!(22				closure!(clone b, clone args, clone context_creator, || evaluate_method(23					context_creator.0(this.clone(), super_obj.clone()),24					&b.value,25					args.clone()26				))27			))),28		)29	} else {30		(31			b.name.clone(),32				binding!(move |this, super_obj| {33					println!("Evaluating binding");34					Val::Lazy(lazy_val!(35					closure!(clone context_creator, clone b, || evaluate(36						context_creator.0(this.clone(), super_obj.clone()),37						&b.value38					))39				))40			}),41		)42	}43}4445pub fn evaluate_method(ctx: Context, expr: &Expr, arg_spec: ParamsDesc) -> Val {46	Val::Func(FuncDesc {47		ctx,48		params: arg_spec,49		eval_rhs: function_rhs!(closure!(clone expr, |ctx| evaluate(ctx, &expr))),50		eval_default: function_default!(|ctx, default| evaluate(ctx, &default)),51	})52}5354pub fn evaluate_field_name(context: Context, field_name: &jsonnet_parser::FieldName) -> String {55	match field_name {56		jsonnet_parser::FieldName::Fixed(n) => n.clone(),57		jsonnet_parser::FieldName::Dyn(expr) => {58			let name = evaluate(context, expr).unwrap_if_lazy();59			match name {60				Val::Str(n) => n,61				_ => panic!(62					"dynamic field name can be only evaluated to 'string', got: {:?}",63					name64				),65			}66		}67	}68}6970pub fn evaluate_unary_op(op: UnaryOpType, b: &Val) -> Val {71	match (op, b) {72		(o, Val::Lazy(l)) => evaluate_unary_op(o, &l.0()),73		(UnaryOpType::Not, Val::Literal(LiteralType::True)) => Val::Literal(LiteralType::False),74		(UnaryOpType::Not, Val::Literal(LiteralType::False)) => Val::Literal(LiteralType::True),75		(op, o) => panic!("unary op not implemented: {:?} {:?}", op, o),76	}77}7879pub fn evaluate_binary_op(a: &Val, op: BinaryOpType, b: &Val) -> Val {80	match (a, op, b) {81		(Val::Lazy(a), o, b) => evaluate_binary_op(&a.0(), o, b),82		(a, o, Val::Lazy(b)) => evaluate_binary_op(a, o, &b.0()),8384		(Val::Str(v1), BinaryOpType::Add, Val::Str(v2)) => Val::Str(v1.to_owned() + &v2),85		(Val::Str(v1), BinaryOpType::Eq, Val::Str(v2)) => bool_val(v1 == v2),86		(Val::Str(v1), BinaryOpType::Ne, Val::Str(v2)) => bool_val(v1 != v2),8788		(Val::Str(v1), BinaryOpType::Add, Val::Num(v2)) => Val::Str(format!("{}{}", v1, v2)),89		(Val::Str(v1), BinaryOpType::Mul, Val::Num(v2)) => Val::Str(v1.repeat(*v2 as usize)),9091		(Val::Obj(v1), BinaryOpType::Add, Val::Obj(v2)) => Val::Obj(v2.with_super(v1.clone())),9293		(Val::Arr(a), BinaryOpType::Add, Val::Arr(b)) => Val::Arr([&a[..], &b[..]].concat()),9495		(Val::Num(v1), BinaryOpType::Mul, Val::Num(v2)) => Val::Num(v1 * v2),96		(Val::Num(v1), BinaryOpType::Div, Val::Num(v2)) => Val::Num(v1 / v2),97		(Val::Num(v1), BinaryOpType::Mod, Val::Num(v2)) => Val::Num(v1 % v2),9899		(Val::Num(v1), BinaryOpType::Add, Val::Num(v2)) => Val::Num(v1 + v2),100		(Val::Num(v1), BinaryOpType::Sub, Val::Num(v2)) => Val::Num(v1 - v2),101102		(Val::Num(v1), BinaryOpType::Lhs, Val::Num(v2)) => {103			Val::Num(((*v1 as i32) << (*v2 as i32)) as f64)104		}105		(Val::Num(v1), BinaryOpType::Rhs, Val::Num(v2)) => {106			Val::Num(((*v1 as i32) >> (*v2 as i32)) as f64)107		}108109		(Val::Num(v1), BinaryOpType::Lt, Val::Num(v2)) => bool_val(v1 < v2),110		(Val::Num(v1), BinaryOpType::Gt, Val::Num(v2)) => bool_val(v1 > v2),111		(Val::Num(v1), BinaryOpType::Lte, Val::Num(v2)) => bool_val(v1 <= v2),112		(Val::Num(v1), BinaryOpType::Gte, Val::Num(v2)) => bool_val(v1 >= v2),113114		(Val::Num(v1), BinaryOpType::Eq, Val::Num(v2)) => bool_val((v1 - v2).abs() < f64::EPSILON),115		(Val::Num(v1), BinaryOpType::Ne, Val::Num(v2)) => bool_val((v1 - v2).abs() > f64::EPSILON),116117		(Val::Num(v1), BinaryOpType::BitAnd, Val::Num(v2)) => {118			Val::Num(((*v1 as i32) & (*v2 as i32)) as f64)119		}120		(Val::Num(v1), BinaryOpType::BitOr, Val::Num(v2)) => {121			Val::Num(((*v1 as i32) | (*v2 as i32)) as f64)122		}123		(Val::Num(v1), BinaryOpType::BitXor, Val::Num(v2)) => {124			Val::Num(((*v1 as i32) ^ (*v2 as i32)) as f64)125		}126		_ => panic!("no rules for binary operation: {:?} {:?} {:?}", a, op, b),127	}128}129130future_wrapper!(HashMap<String, Binding>, FutureNewBindings);131future_wrapper!(ObjValue, FutureObjValue);132133// TODO: Asserts134pub fn evaluate_object(context: Context, object: ObjBody) -> ObjValue {135	match object {136		ObjBody::MemberList(members) => {137			let future_bindings = FutureNewBindings::new();138			let future_this = FutureObjValue::new();139			let context_creator = context_creator!(140				closure!(clone context, clone future_bindings, |this: Option<ObjValue>, super_obj: Option<ObjValue>| {141					println!("Context created");142					context.clone().extend(143						future_bindings.clone().unwrap(),144						context.clone().dollar().clone().or_else(||this.clone()),145						this,146						super_obj147					)148				})149			);150			let mut bindings: HashMap<String, Binding> = HashMap::new();151			for (n, b) in members152				.iter()153				.filter_map(|m| match m {154					Member::BindStmt(b) => Some(b.clone()),155					_ => None,156				})157				.map(|b| {158					evaluate_binding(&b, context_creator.clone())159				})160			{161				bindings.insert(n, b);162			}163			future_bindings.fill(bindings);164165			println!("Bindings filled");166			let mut new_members = BTreeMap::new();167			for member in members.into_iter() {168				match member {169					Member::Field(FieldMember {170						name,171						plus,172						params: None,173						visibility,174						value,175					}) => {176						let name = evaluate_field_name(context.clone(), &name);177						new_members.insert(178							name,179							ObjMember {180								add: plus,181								visibility: visibility.clone(),182								invoke: binding!(183									closure!(clone value, clone context_creator, clone future_this, |this, super_obj| {184										// FIXME: I should take "this" instead of "future_this" there?185										// TODO: Assert186										evaluate(187											context_creator.0(this, super_obj),188											&value,189										)190									})191								),192							},193						);194					}195					Member::Field(FieldMember {196						name,197						params: Some(params),198						value,199						..200					}) => {201						let name = evaluate_field_name(context.clone(), &name);202						new_members.insert(203							name,204							ObjMember {205								add: false,206								visibility: Visibility::Hidden,207								invoke: binding!(208									closure!(clone value, clone context_creator, clone future_this, |this, super_obj| {209										// FIXME: I should take "this" instead of "future_this" there?210										// TODO: Assert211										evaluate_method(212											context_creator.0(this, super_obj),213											&value.clone(),214											params.clone(),215										)216									})217								),218							},219						);220					}221					Member::BindStmt(_) => {}222					Member::AssertStmt(_) => {}223				}224			}225			future_this.fill(ObjValue::new(None, Rc::new(new_members)))226		}227		_ => todo!(),228	}229}230231pub fn evaluate(context: Context, expr: &Expr) -> Val {232	use Expr::*;233	match &*expr {234		Literal(LiteralType::This) => {235			println!("{:?}", context.this());236			Val::Obj(237				context238					.this()239					.clone()240					.unwrap_or_else(|| panic!("this not found")),241			)242		}243		Literal(LiteralType::Super) => Val::Obj(244			context245				.super_obj()246				.clone()247				.unwrap_or_else(|| panic!("super not found")),248		),249		Literal(t) => Val::Literal(t.clone()),250		Parened(e) => evaluate(context, e),251		Str(v) => Val::Str(v.clone()),252		Num(v) => Val::Num(*v),253		BinaryOp(v1, o, v2) => {254			evaluate_binary_op(&evaluate(context.clone(), v1), *o, &evaluate(context, v2))255		}256		UnaryOp(o, v) => evaluate_unary_op(*o, &evaluate(context, v)),257		Var(name) => {258			let variable = context.binding(&name);259			variable.0(None, None).unwrap_if_lazy()260		}261		Index(box value, box index) => {262			match (263				evaluate(context.clone(), value).unwrap_if_lazy(),264				evaluate(context, index),265			) {266				(Val::Obj(v), Val::Str(s)) => v267					.get(&s)268					.unwrap_or_else(|| panic!("{} not found in {:?}", s, v)),269				(Val::Arr(v), Val::Num(n)) => v270					.get(n as usize)271					.unwrap_or_else(|| panic!("out of bounds"))272					.clone(),273				(v, i) => todo!("not implemented: {:?}[{:?}]", v, i.unwrap_if_lazy()),274			}275		}276		LocalExpr(bindings, returned) => {277			let mut new_bindings: HashMap<String, Binding> = HashMap::new();278			let future_context = Context::new_future();279280			let context_creator = context_creator!(281				closure!(clone future_context, |_, _| future_context.clone().unwrap())282			);283284			for (k, v) in bindings285				.iter()286				.map(move |b| evaluate_binding(b, context_creator.clone()))287			{288				new_bindings.insert(k, v);289			}290291			let context = context292				.extend(new_bindings, None, None, None)293				.into_future(future_context);294			evaluate(context, &*returned.clone())295		}296		Obj(body) => Val::Obj(evaluate_object(context, body.clone())),297		Apply(box value, ArgsDesc(args)) => {298			let value = evaluate(context.clone(), value).unwrap_if_lazy();299			match value {300				Val::Func(f) => f.evaluate(301					args.clone()302						.into_iter()303						.map(|a| {304							(305								a.clone().0,306								Val::Lazy(lazy_val!(307									closure!(clone context, clone a, || evaluate(context.clone(), &a.clone().1))308								)),309							)310						})311						.collect(),312				),313				_ => panic!("{:?} is not a function", value),314			}315		}316		Function(params, body) => evaluate_method(context, body, params.clone()),317		Error(e) => panic!("error: {}", evaluate(context, e)),318		IfElse {319			cond,320			cond_then,321			cond_else,322		} => match evaluate(context.clone(), &cond.0).unwrap_if_lazy() {323			Val::Literal(LiteralType::True) => evaluate(context, cond_then),324			Val::Literal(LiteralType::False) => match cond_else {325				Some(v) => evaluate(context, v),326				None => Val::Literal(LiteralType::False),327			},328			v => panic!("if condition evaluated to {:?} (boolean needed instead)", v),329		},330		_ => panic!("evaluation not implemented: {:?}", expr),331	}332}
after · crates/jsonnet-evaluator/src/evaluate.rs
1use crate::{2	binding, bool_val, context_creator, function_default, function_rhs, future_wrapper, lazy_val,3	Binding, Context, ContextCreator, FuncDesc, ObjMember, ObjValue, Val,4};5use closure::closure;6use jsonnet_parser::{7	ArgsDesc, BinaryOpType, BindSpec, Expr, FieldMember, LiteralType, Member, ObjBody, ParamsDesc,8	UnaryOpType, Visibility,9};10use std::{11	collections::{BTreeMap, HashMap},12	rc::Rc,13};1415pub fn evaluate_binding(b: &BindSpec, context_creator: ContextCreator) -> (String, Binding) {16	let b = b.clone();17	if let Some(args) = &b.params {18		let args = args.clone();19		(20			b.name.clone(),21			binding!(move |this, super_obj| Val::Lazy(lazy_val!(22				closure!(clone b, clone args, clone context_creator, || evaluate_method(23					context_creator.0(this.clone(), super_obj.clone()),24					&b.value,25					args.clone()26				))27			))),28		)29	} else {30		(31			b.name.clone(),32			binding!(move |this, super_obj| {33				Val::Lazy(lazy_val!(34					closure!(clone context_creator, clone b, || evaluate(35						context_creator.0(this.clone(), super_obj.clone()),36						&b.value37					))38				))39			}),40		)41	}42}4344pub fn evaluate_method(ctx: Context, expr: &Expr, arg_spec: ParamsDesc) -> Val {45	Val::Func(FuncDesc {46		ctx,47		params: arg_spec,48		eval_rhs: function_rhs!(closure!(clone expr, |ctx| evaluate(ctx, &expr))),49		eval_default: function_default!(|ctx, default| evaluate(ctx, &default)),50	})51}5253pub fn evaluate_field_name(context: Context, field_name: &jsonnet_parser::FieldName) -> String {54	match field_name {55		jsonnet_parser::FieldName::Fixed(n) => n.clone(),56		jsonnet_parser::FieldName::Dyn(expr) => {57			let name = evaluate(context, expr).unwrap_if_lazy();58			match name {59				Val::Str(n) => n,60				_ => panic!(61					"dynamic field name can be only evaluated to 'string', got: {:?}",62					name63				),64			}65		}66	}67}6869pub fn evaluate_unary_op(op: UnaryOpType, b: &Val) -> Val {70	match (op, b) {71		(o, Val::Lazy(l)) => evaluate_unary_op(o, &l.0()),72		(UnaryOpType::Not, Val::Literal(LiteralType::True)) => Val::Literal(LiteralType::False),73		(UnaryOpType::Not, Val::Literal(LiteralType::False)) => Val::Literal(LiteralType::True),74		(op, o) => panic!("unary op not implemented: {:?} {:?}", op, o),75	}76}7778pub fn evaluate_binary_op(a: &Val, op: BinaryOpType, b: &Val) -> Val {79	match (a, op, b) {80		(Val::Lazy(a), o, b) => evaluate_binary_op(&a.0(), o, b),81		(a, o, Val::Lazy(b)) => evaluate_binary_op(a, o, &b.0()),8283		(Val::Str(v1), BinaryOpType::Add, Val::Str(v2)) => Val::Str(v1.to_owned() + &v2),84		(Val::Str(v1), BinaryOpType::Eq, Val::Str(v2)) => bool_val(v1 == v2),85		(Val::Str(v1), BinaryOpType::Ne, Val::Str(v2)) => bool_val(v1 != v2),8687		(Val::Str(v1), BinaryOpType::Add, Val::Num(v2)) => Val::Str(format!("{}{}", v1, v2)),88		(Val::Str(v1), BinaryOpType::Mul, Val::Num(v2)) => Val::Str(v1.repeat(*v2 as usize)),8990		(Val::Obj(v1), BinaryOpType::Add, Val::Obj(v2)) => Val::Obj(v2.with_super(v1.clone())),9192		(Val::Arr(a), BinaryOpType::Add, Val::Arr(b)) => Val::Arr([&a[..], &b[..]].concat()),9394		(Val::Num(v1), BinaryOpType::Mul, Val::Num(v2)) => Val::Num(v1 * v2),95		(Val::Num(v1), BinaryOpType::Div, Val::Num(v2)) => Val::Num(v1 / v2),96		(Val::Num(v1), BinaryOpType::Mod, Val::Num(v2)) => Val::Num(v1 % v2),9798		(Val::Num(v1), BinaryOpType::Add, Val::Num(v2)) => Val::Num(v1 + v2),99		(Val::Num(v1), BinaryOpType::Sub, Val::Num(v2)) => Val::Num(v1 - v2),100101		(Val::Num(v1), BinaryOpType::Lhs, Val::Num(v2)) => {102			Val::Num(((*v1 as i32) << (*v2 as i32)) as f64)103		}104		(Val::Num(v1), BinaryOpType::Rhs, Val::Num(v2)) => {105			Val::Num(((*v1 as i32) >> (*v2 as i32)) as f64)106		}107108		(Val::Num(v1), BinaryOpType::Lt, Val::Num(v2)) => bool_val(v1 < v2),109		(Val::Num(v1), BinaryOpType::Gt, Val::Num(v2)) => bool_val(v1 > v2),110		(Val::Num(v1), BinaryOpType::Lte, Val::Num(v2)) => bool_val(v1 <= v2),111		(Val::Num(v1), BinaryOpType::Gte, Val::Num(v2)) => bool_val(v1 >= v2),112113		(Val::Num(v1), BinaryOpType::Eq, Val::Num(v2)) => bool_val((v1 - v2).abs() < f64::EPSILON),114		(Val::Num(v1), BinaryOpType::Ne, Val::Num(v2)) => bool_val((v1 - v2).abs() > f64::EPSILON),115116		(Val::Num(v1), BinaryOpType::BitAnd, Val::Num(v2)) => {117			Val::Num(((*v1 as i32) & (*v2 as i32)) as f64)118		}119		(Val::Num(v1), BinaryOpType::BitOr, Val::Num(v2)) => {120			Val::Num(((*v1 as i32) | (*v2 as i32)) as f64)121		}122		(Val::Num(v1), BinaryOpType::BitXor, Val::Num(v2)) => {123			Val::Num(((*v1 as i32) ^ (*v2 as i32)) as f64)124		}125		_ => panic!("no rules for binary operation: {:?} {:?} {:?}", a, op, b),126	}127}128129future_wrapper!(HashMap<String, Binding>, FutureNewBindings);130future_wrapper!(ObjValue, FutureObjValue);131132// TODO: Asserts133pub fn evaluate_object(context: Context, object: ObjBody) -> ObjValue {134	match object {135		ObjBody::MemberList(members) => {136			let future_bindings = FutureNewBindings::new();137			let future_this = FutureObjValue::new();138			let context_creator = context_creator!(139				closure!(clone context, clone future_bindings, clone future_this, |this: Option<ObjValue>, super_obj: Option<ObjValue>| {140					context.clone().extend(141						future_bindings.clone().unwrap(),142						context.clone().dollar().clone().or_else(||this.clone()),143						Some(future_this.clone().unwrap()),144						super_obj145					)146				})147			);148			let mut bindings: HashMap<String, Binding> = HashMap::new();149			for (n, b) in members150				.iter()151				.filter_map(|m| match m {152					Member::BindStmt(b) => Some(b.clone()),153					_ => None,154				})155				.map(|b| evaluate_binding(&b, context_creator.clone()))156			{157				bindings.insert(n, b);158			}159			future_bindings.fill(bindings);160161			let mut new_members = BTreeMap::new();162			for member in members.into_iter() {163				match member {164					Member::Field(FieldMember {165						name,166						plus,167						params: None,168						visibility,169						value,170					}) => {171						let name = evaluate_field_name(context.clone(), &name);172						new_members.insert(173							name,174							ObjMember {175								add: plus,176								visibility: visibility.clone(),177								invoke: binding!(178									closure!(clone value, clone context_creator, |this, super_obj| {179										// TODO: Assert180										evaluate(181											context_creator.0(this, super_obj),182											&value,183										)184									})185								),186							},187						);188					}189					Member::Field(FieldMember {190						name,191						params: Some(params),192						value,193						..194					}) => {195						let name = evaluate_field_name(context.clone(), &name);196						new_members.insert(197							name,198							ObjMember {199								add: false,200								visibility: Visibility::Hidden,201								invoke: binding!(202									closure!(clone value, clone context_creator, |this, super_obj| {203										// TODO: Assert204										evaluate_method(205											context_creator.0(this, super_obj),206											&value.clone(),207											params.clone(),208										)209									})210								),211							},212						);213					}214					Member::BindStmt(_) => {}215					Member::AssertStmt(_) => {}216				}217			}218			future_this.fill(ObjValue::new(None, Rc::new(new_members)))219		}220		_ => todo!(),221	}222}223224pub fn evaluate(context: Context, expr: &Expr) -> Val {225	use Expr::*;226	match &*expr {227		Literal(LiteralType::This) => Val::Obj(228			context229				.this()230				.clone()231				.unwrap_or_else(|| panic!("this not found")),232		),233		Literal(LiteralType::Super) => Val::Obj(234			context235				.super_obj()236				.clone()237				.unwrap_or_else(|| panic!("super not found")),238		),239		Literal(t) => Val::Literal(t.clone()),240		Parened(e) => evaluate(context, e),241		Str(v) => Val::Str(v.clone()),242		Num(v) => Val::Num(*v),243		BinaryOp(v1, o, v2) => {244			evaluate_binary_op(&evaluate(context.clone(), v1), *o, &evaluate(context, v2))245		}246		UnaryOp(o, v) => evaluate_unary_op(*o, &evaluate(context, v)),247		Var(name) => {248			let variable = context.binding(&name);249			variable.0(None, None).unwrap_if_lazy()250		}251		Index(box value, box index) => {252			match (253				evaluate(context.clone(), value).unwrap_if_lazy(),254				evaluate(context, index),255			) {256				(Val::Obj(v), Val::Str(s)) => v257					.get(&s)258					.unwrap_or_else(|| panic!("{} not found in {:?}", s, v)),259				(Val::Arr(v), Val::Num(n)) => v260					.get(n as usize)261					.unwrap_or_else(|| panic!("out of bounds"))262					.clone(),263				(v, i) => todo!("not implemented: {:?}[{:?}]", v, i.unwrap_if_lazy()),264			}265		}266		LocalExpr(bindings, returned) => {267			let mut new_bindings: HashMap<String, Binding> = HashMap::new();268			let future_context = Context::new_future();269270			let context_creator = context_creator!(271				closure!(clone future_context, |_, _| future_context.clone().unwrap())272			);273274			for (k, v) in bindings275				.iter()276				.map(move |b| evaluate_binding(b, context_creator.clone()))277			{278				new_bindings.insert(k, v);279			}280281			let context = context282				.extend(new_bindings, None, None, None)283				.into_future(future_context);284			evaluate(context, &*returned.clone())285		}286		Obj(body) => Val::Obj(evaluate_object(context, body.clone())),287		Apply(box value, ArgsDesc(args)) => {288			let value = evaluate(context.clone(), value).unwrap_if_lazy();289			match value {290				Val::Func(f) => f.evaluate(291					args.clone()292						.into_iter()293						.map(|a| {294							(295								a.clone().0,296								Val::Lazy(lazy_val!(297									closure!(clone context, clone a, || evaluate(context.clone(), &a.clone().1))298								)),299							)300						})301						.collect(),302				),303				_ => panic!("{:?} is not a function", value),304			}305		}306		Function(params, body) => evaluate_method(context, body, params.clone()),307		Error(e) => panic!("error: {}", evaluate(context, e)),308		IfElse {309			cond,310			cond_then,311			cond_else,312		} => match evaluate(context.clone(), &cond.0).unwrap_if_lazy() {313			Val::Literal(LiteralType::True) => evaluate(context, cond_then),314			Val::Literal(LiteralType::False) => match cond_else {315				Some(v) => evaluate(context, v),316				None => Val::Literal(LiteralType::False),317			},318			v => panic!("if condition evaluated to {:?} (boolean needed instead)", v),319		},320		_ => panic!("evaluation not implemented: {:?}", expr),321	}322}
modifiedcrates/jsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- a/crates/jsonnet-evaluator/src/lib.rs
+++ b/crates/jsonnet-evaluator/src/lib.rs
@@ -193,7 +193,7 @@
 		// referenced from field
 		eval_stdlib!(
 			r#"{
-				local me = std.trace("test", self),
+				local me = self,
 				b: me,
 			}.b"#
 		);