git.delta.rocks / jrsonnet / refs/commits / a7e4b59c444f

difftreelog

fix parser should parse import argument as an expression

Yaroslav Bolyukin2022-11-10parent: #8d4d5b7.patch.diff
in: master

4 files changed

modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
17 tb, throw,17 tb, throw,
18 typed::Typed,18 typed::Typed,
19 val::{ArrValue, CachedUnbound, IndexableVal, Thunk, ThunkValue},19 val::{ArrValue, CachedUnbound, IndexableVal, Thunk, ThunkValue},
20 Context, GcHashMap, ObjValue, ObjValueBuilder, ObjectAssertion, Pending, Result, State,20 Context, GcHashMap, LocError, ObjValue, ObjValueBuilder, ObjectAssertion, Pending, Result,
21 Unbound, Val,21 ResultExt, State, Unbound, Val,
22};22};
23pub mod destructure;23pub mod destructure;
24pub mod operator;24pub mod operator;
591 IndexableVal::into_untyped(indexable.into_indexable()?.slice(start, end, step)?)?591 IndexableVal::into_untyped(indexable.into_indexable()?.slice(start, end, step)?)?
592 }592 }
593 i @ (Import(path) | ImportStr(path) | ImportBin(path)) => {593 i @ (Import(path) | ImportStr(path) | ImportBin(path)) => {
594 let Expr::Str(path) = &*path.0 else {
595 throw!("computed imports are not supported")
596 };
594 let tmp = loc.clone().0;597 let tmp = loc.clone().0;
595 let s = ctx.state();598 let s = ctx.state();
596 let resolved_path = s.resolve_from(tmp.source_path(), path as &str)?;599 let resolved_path = s.resolve_from(tmp.source_path(), path as &str)?;
modifiedcrates/jrsonnet-evaluator/src/tla.rsdiffbeforeafterboth

no syntactic changes

modifiedcrates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth
390 LocalExpr(Vec<BindSpec>, LocExpr),390 LocalExpr(Vec<BindSpec>, LocExpr),
391391
392 /// import "hello"392 /// import "hello"
393 Import(IStr),393 Import(LocExpr),
394 /// importStr "file.txt"394 /// importStr "file.txt"
395 ImportStr(IStr),395 ImportStr(LocExpr),
396 /// importBin "file.txt"396 /// importBin "file.txt"
397 ImportBin(IStr),397 ImportBin(LocExpr),
398 /// error "I'm broken"398 /// error "I'm broken"
399 ErrorStmt(LocExpr),399 ErrorStmt(LocExpr),
400 /// a(b, c)400 /// a(b, c)
modifiedcrates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth
257 / array_expr(s)257 / array_expr(s)
258 / array_comp_expr(s)258 / array_comp_expr(s)
259259
260 / 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)}
263263
264 / var_expr(s)264 / var_expr(s)
265 / local_expr(s)265 / local_expr(s)