difftreelog
fix(evaluator) indirect_self bug
in: master
4 files changed
Cargo.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",
]
crates/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());
crates/jsonnet-evaluator/src/evaluate.rsdiffbeforeafterboth30 (30 (31 b.name.clone(),31 b.name.clone(),32 binding!(move |this, super_obj| {32 binding!(move |this, super_obj| {33 println!("Evaluating binding");34 Val::Lazy(lazy_val!(33 Val::Lazy(lazy_val!(35 closure!(clone context_creator, clone b, || evaluate(34 closure!(clone context_creator, clone b, || evaluate(36 context_creator.0(this.clone(), super_obj.clone()),35 context_creator.0(this.clone(), super_obj.clone()),137 let future_bindings = FutureNewBindings::new();136 let future_bindings = FutureNewBindings::new();138 let future_this = FutureObjValue::new();137 let future_this = FutureObjValue::new();139 let context_creator = context_creator!(138 let context_creator = context_creator!(140 closure!(clone context, clone future_bindings, |this: Option<ObjValue>, super_obj: Option<ObjValue>| {139 closure!(clone context, clone future_bindings, clone future_this, |this: Option<ObjValue>, super_obj: Option<ObjValue>| {141 println!("Context created");142 context.clone().extend(140 context.clone().extend(143 future_bindings.clone().unwrap(),141 future_bindings.clone().unwrap(),144 context.clone().dollar().clone().or_else(||this.clone()),142 context.clone().dollar().clone().or_else(||this.clone()),145 this,143 Some(future_this.clone().unwrap()),146 super_obj144 super_obj147 )145 )148 })146 })154 Member::BindStmt(b) => Some(b.clone()),152 Member::BindStmt(b) => Some(b.clone()),155 _ => None,153 _ => None,156 })154 })157 .map(|b| {155 .map(|b| evaluate_binding(&b, context_creator.clone()))158 evaluate_binding(&b, context_creator.clone())159 })160 {156 {161 bindings.insert(n, b);157 bindings.insert(n, b);162 }158 }163 future_bindings.fill(bindings);159 future_bindings.fill(bindings);164160165 println!("Bindings filled");166 let mut new_members = BTreeMap::new();161 let mut new_members = BTreeMap::new();167 for member in members.into_iter() {162 for member in members.into_iter() {168 match member {163 match member {180 add: plus,175 add: plus,181 visibility: visibility.clone(),176 visibility: visibility.clone(),182 invoke: binding!(177 invoke: binding!(183 closure!(clone value, clone context_creator, clone future_this, |this, super_obj| {178 closure!(clone value, clone context_creator, |this, super_obj| {184 // FIXME: I should take "this" instead of "future_this" there?185 // TODO: Assert179 // TODO: Assert186 evaluate(180 evaluate(187 context_creator.0(this, super_obj),181 context_creator.0(this, super_obj),205 add: false,199 add: false,206 visibility: Visibility::Hidden,200 visibility: Visibility::Hidden,207 invoke: binding!(201 invoke: binding!(208 closure!(clone value, clone context_creator, clone future_this, |this, super_obj| {202 closure!(clone value, clone context_creator, |this, super_obj| {209 // FIXME: I should take "this" instead of "future_this" there?210 // TODO: Assert203 // TODO: Assert211 evaluate_method(204 evaluate_method(212 context_creator.0(this, super_obj),205 context_creator.0(this, super_obj),231pub fn evaluate(context: Context, expr: &Expr) -> Val {224pub fn evaluate(context: Context, expr: &Expr) -> Val {232 use Expr::*;225 use Expr::*;233 match &*expr {226 match &*expr {234 Literal(LiteralType::This) => {227 Literal(LiteralType::This) => Val::Obj(235 println!("{:?}", context.this());236 Val::Obj(237 context228 context238 .this()229 .this()239 .clone()230 .clone()240 .unwrap_or_else(|| panic!("this not found")),231 .unwrap_or_else(|| panic!("this not found")),241 )232 ),242 }243 Literal(LiteralType::Super) => Val::Obj(233 Literal(LiteralType::Super) => Val::Obj(244 context234 context245 .super_obj()235 .super_obj()crates/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"#
);