difftreelog
fix parser should parse import argument as an expression
in: master
4 files changed
crates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/evaluate/mod.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/mod.rs
@@ -17,8 +17,8 @@
tb, throw,
typed::Typed,
val::{ArrValue, CachedUnbound, IndexableVal, Thunk, ThunkValue},
- Context, GcHashMap, ObjValue, ObjValueBuilder, ObjectAssertion, Pending, Result, State,
- Unbound, Val,
+ Context, GcHashMap, LocError, ObjValue, ObjValueBuilder, ObjectAssertion, Pending, Result,
+ ResultExt, State, Unbound, Val,
};
pub mod destructure;
pub mod operator;
@@ -591,6 +591,9 @@
IndexableVal::into_untyped(indexable.into_indexable()?.slice(start, end, step)?)?
}
i @ (Import(path) | ImportStr(path) | ImportBin(path)) => {
+ let Expr::Str(path) = &*path.0 else {
+ throw!("computed imports are not supported")
+ };
let tmp = loc.clone().0;
let s = ctx.state();
let resolved_path = s.resolve_from(tmp.source_path(), path as &str)?;
crates/jrsonnet-evaluator/src/tla.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/tla.rs
+++ b/crates/jrsonnet-evaluator/src/tla.rs
@@ -12,7 +12,10 @@
|| "during TLA call".to_owned(),
|| {
func.evaluate(
- s.create_default_context(Source::new_virtual("<top-level-arg>".into(), IStr::empty())),
+ s.create_default_context(Source::new_virtual(
+ "<top-level-arg>".into(),
+ IStr::empty(),
+ )),
CallLocation::native(),
args,
false,
crates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/expr.rs
+++ b/crates/jrsonnet-parser/src/expr.rs
@@ -390,11 +390,11 @@
LocalExpr(Vec<BindSpec>, LocExpr),
/// import "hello"
- Import(IStr),
+ Import(LocExpr),
/// importStr "file.txt"
- ImportStr(IStr),
+ ImportStr(LocExpr),
/// importBin "file.txt"
- ImportBin(IStr),
+ ImportBin(LocExpr),
/// error "I'm broken"
ErrorStmt(LocExpr),
/// a(b, c)
crates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth257 / array_expr(s)257 / array_expr(s)258 / array_comp_expr(s)258 / array_comp_expr(s)259259260 / keyword("importstr") _ path:string() {Expr::ImportStr(path.into())}260 / keyword("importstr") _ path:expr(s) {Expr::ImportStr(path)}261 / keyword("importbin") _ path:string() {Expr::ImportBin(path.into())}261 / keyword("importbin") _ path:expr(s) {Expr::ImportBin(path)}262 / keyword("import") _ path:string() {Expr::Import(path.into())}262 / keyword("import") _ path:expr(s) {Expr::Import(path)}263263264 / var_expr(s)264 / var_expr(s)265 / local_expr(s)265 / local_expr(s)