difftreelog
feat support legacy std.thisFile
in: master
5 files changed
crates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth140 #[error("sort error: {0}")]140 #[error("sort error: {0}")]141 Sort(#[from] SortError),141 Sort(#[from] SortError),142143 /// Thrown as error, as this is legacy feature, and error here144 /// is acceptable for defeating object field cache145 #[error("should not reach outside: std.thisFile")]146 MagicThisFileUsed,142147143 #[cfg(feature = "anyhow-error")]148 #[cfg(feature = "anyhow-error")]144 #[error(transparent)]149 #[error(transparent)]crates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth568 (Val::Obj(v), Val::Str(key)) => s.push(568 (Val::Obj(v), Val::Str(key)) => s.push(569 CallLocation::new(loc),569 CallLocation::new(loc),570 || format!("field <{}> access", key),570 || format!("field <{}> access", key),571 || {571 || match v.get(s.clone(), key.clone()) {572 if let Some(v) = v.get(s.clone(), key.clone())? {573 Ok(v)572 Ok(Some(v)) => Ok(v),574 } else {575 throw!(NoSuchField(key.clone()))573 Ok(None) => throw!(NoSuchField(key.clone())),576 }574 Err(e) if matches!(e.error(), MagicThisFileUsed) => {577 },575 Ok(Val::Str(loc.0.to_string_lossy().into()))576 }577 Err(e) => Err(e),578 },578 )?,579 )?,579 (Val::Obj(_), n) => throw!(ValueIndexMustBeTypeGot(580 (Val::Obj(_), n) => throw!(ValueIndexMustBeTypeGot(580 ValType::Obj,581 ValType::Obj,674 .with(|b| b.get(name).copied())675 .with(|b| b.get(name).copied())675 .ok_or_else(|| IntrinsicNotFound(name.clone()))?,676 .ok_or_else(|| IntrinsicNotFound(name.clone()))?,676 )),677 )),678 IntrinsicThisFile => return Err(MagicThisFileUsed.into()),677 AssertExpr(assert, returned) => {679 AssertExpr(assert, returned) => {678 evaluate_assert(s.clone(), ctx.clone(), assert)?;680 evaluate_assert(s.clone(), ctx.clone(), assert)?;679 evaluate(s, ctx, returned)?681 evaluate(s, ctx, returned)?crates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth296 Index(LocExpr, LocExpr),296 Index(LocExpr, LocExpr),297 /// function(x) x297 /// function(x) x298 Function(ParamsDesc, LocExpr),298 Function(ParamsDesc, LocExpr),299 /// std.thisFile300 IntrinsicThisFile,299 /// std.primitiveEquals301 /// std.primitiveEquals300 Intrinsic(IStr),302 Intrinsic(IStr),301 /// if true == false then 1 else 2303 /// if true == false then 1 else 2crates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth210 pub rule expr_basic(s: &ParserSettings) -> Expr210 pub rule expr_basic(s: &ParserSettings) -> Expr211 = literal(s)211 = literal(s)212212213 / quiet!{"$intrinsic(" name:$(id()) ")" {Expr::Intrinsic(name.into())}}213 / quiet!{"$intrinsicThisFile" {Expr::IntrinsicThisFile}}214 / quiet!{"$intrinsic(" name:$(id()) ")" {Expr::Intrinsic(name.into())}}214215215 / string_expr(s) / number_expr(s)216 / string_expr(s) / number_expr(s)216 / array_expr(s)217 / array_expr(s)crates/jrsonnet-stdlib/src/std.jsonnetdiffbeforeafterboth2 local std = self,2 local std = self,3 local id = std.id,3 local id = std.id,445 # Magic legacy field6 thisFile:: $intrinsicThisFile,75 # Those functions aren't normally located in stdlib8 # Those functions aren't normally located in stdlib6 length:: $intrinsic(length),9 length:: $intrinsic(length),7 type:: $intrinsic(type),10 type:: $intrinsic(type),