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.rsdiffbeforeafterbothno syntactic changes
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.rsdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/lib.rs
+++ b/crates/jrsonnet-parser/src/lib.rs
@@ -257,9 +257,9 @@
/ array_expr(s)
/ array_comp_expr(s)
- / keyword("importstr") _ path:string() {Expr::ImportStr(path.into())}
- / keyword("importbin") _ path:string() {Expr::ImportBin(path.into())}
- / keyword("import") _ path:string() {Expr::Import(path.into())}
+ / keyword("importstr") _ path:expr(s) {Expr::ImportStr(path)}
+ / keyword("importbin") _ path:expr(s) {Expr::ImportBin(path)}
+ / keyword("import") _ path:expr(s) {Expr::Import(path)}
/ var_expr(s)
/ local_expr(s)