difftreelog
fix(evaluator) indirect_self bug
in: master
4 files changed
Cargo.lockdiffbeforeafterboth9 packageslockfile v1
Might be heavy and slow!
jsonnet-evaluator
0.1.0workspace↘ 2↖ 0depends onjsonnet-parser
0.1.0workspace↘ 2↖ 1depends onused byjsonnet-stdlib
0.1.0workspace↘ 0↖ 2peg
0.6.2crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9075875c14bb21f25f11cad4b6ad2e4dd443b8fb83900b2fbdd6ebd744b82e97depends onused bypeg-macros
0.6.2crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc24c165fd39e995246140cc78df55c56c6733ba87e6658cb3e197b8856c62852used bypeg-runtime
0.6.2crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum0c1a2897e69d986c7986747ebad425cf03746ec5e3e09bb3b2600f91301ba864used byproc-macro2
1.0.12crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8872cf6f48eee44265156c111456a700ab3483686b3f96df4cf5481c89157319depends onused byquote
1.0.5crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum42934bc9c8ab0d3b273a16d8551c8f0fcff46be73276ca083ec2414c15c4ba5edepends onused byunicode-xid
0.2.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097cused by
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.rsdiffbeforeafterboth--- a/crates/jsonnet-evaluator/src/evaluate.rs
+++ b/crates/jsonnet-evaluator/src/evaluate.rs
@@ -29,9 +29,8 @@
} else {
(
b.name.clone(),
- binding!(move |this, super_obj| {
- println!("Evaluating binding");
- Val::Lazy(lazy_val!(
+ binding!(move |this, super_obj| {
+ Val::Lazy(lazy_val!(
closure!(clone context_creator, clone b, || evaluate(
context_creator.0(this.clone(), super_obj.clone()),
&b.value
@@ -137,12 +136,11 @@
let future_bindings = FutureNewBindings::new();
let future_this = FutureObjValue::new();
let context_creator = context_creator!(
- closure!(clone context, clone future_bindings, |this: Option<ObjValue>, super_obj: Option<ObjValue>| {
- println!("Context created");
+ closure!(clone context, clone future_bindings, clone future_this, |this: Option<ObjValue>, super_obj: Option<ObjValue>| {
context.clone().extend(
future_bindings.clone().unwrap(),
context.clone().dollar().clone().or_else(||this.clone()),
- this,
+ Some(future_this.clone().unwrap()),
super_obj
)
})
@@ -154,15 +152,12 @@
Member::BindStmt(b) => Some(b.clone()),
_ => None,
})
- .map(|b| {
- evaluate_binding(&b, context_creator.clone())
- })
+ .map(|b| evaluate_binding(&b, context_creator.clone()))
{
bindings.insert(n, b);
}
future_bindings.fill(bindings);
- println!("Bindings filled");
let mut new_members = BTreeMap::new();
for member in members.into_iter() {
match member {
@@ -180,8 +175,7 @@
add: plus,
visibility: visibility.clone(),
invoke: binding!(
- closure!(clone value, clone context_creator, clone future_this, |this, super_obj| {
- // FIXME: I should take "this" instead of "future_this" there?
+ closure!(clone value, clone context_creator, |this, super_obj| {
// TODO: Assert
evaluate(
context_creator.0(this, super_obj),
@@ -205,8 +199,7 @@
add: false,
visibility: Visibility::Hidden,
invoke: binding!(
- closure!(clone value, clone context_creator, clone future_this, |this, super_obj| {
- // FIXME: I should take "this" instead of "future_this" there?
+ closure!(clone value, clone context_creator, |this, super_obj| {
// TODO: Assert
evaluate_method(
context_creator.0(this, super_obj),
@@ -231,15 +224,12 @@
pub fn evaluate(context: Context, expr: &Expr) -> Val {
use Expr::*;
match &*expr {
- Literal(LiteralType::This) => {
- println!("{:?}", context.this());
- Val::Obj(
- context
- .this()
- .clone()
- .unwrap_or_else(|| panic!("this not found")),
- )
- }
+ Literal(LiteralType::This) => Val::Obj(
+ context
+ .this()
+ .clone()
+ .unwrap_or_else(|| panic!("this not found")),
+ ),
Literal(LiteralType::Super) => Val::Obj(
context
.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"#
);