git.delta.rocks / jrsonnet / refs/commits / 11555dda9997

difftreelog

fix forward null-coaelse

Yaroslav Bolyukin2023-08-06parent: #ceb1d3e.patch.diff
in: master

4 files changed

modifiedcmds/jrsonnet/Cargo.tomldiffbeforeafterboth
--- a/cmds/jrsonnet/Cargo.toml
+++ b/cmds/jrsonnet/Cargo.toml
@@ -23,7 +23,7 @@
 # Bigint type
 exp-bigint = ["jrsonnet-evaluator/exp-bigint", "jrsonnet-cli/exp-bigint"]
 # obj?.field, obj?.['field']
-exp-null-coaelse = ["jrsonnet-evaluator/exp-null-coaelse", "jrsonnet-parser/exp-null-coaelse"]
+exp-null-coaelse = ["jrsonnet-evaluator/exp-null-coaelse", "jrsonnet-parser/exp-null-coaelse", "jrsonnet-cli/exp-null-coaelse"]
 # --exp-apply
 exp-apply = []
 
modifiedcrates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-cli/Cargo.toml
+++ b/crates/jrsonnet-cli/Cargo.toml
@@ -16,6 +16,10 @@
     "jrsonnet-evaluator/exp-bigint",
     "jrsonnet-stdlib/exp-bigint",
 ]
+exp-null-coaelse = [
+    "jrsonnet-evaluator/exp-null-coaelse",
+    "jrsonnet-stdlib/exp-null-coaelse",
+]
 legacy-this-file = ["jrsonnet-stdlib/legacy-this-file"]
 
 [dependencies]
modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/mod.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/mod.rs
@@ -461,6 +461,10 @@
 				))
 			};
 			let Some(super_obj) = ctx.super_obj() else {
+				#[cfg(feature = "exp-null-coaelse")]
+				if *null_coaelse {
+					return Ok(Val::Null);
+				}
 				throw!(NoSuperFound)
 			};
 			let this = ctx
modifiedcrates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth
before · crates/jrsonnet-stdlib/Cargo.toml
1[package]2name = "jrsonnet-stdlib"3description = "jsonnet standard library packaged as crate"4version.workspace = true5repository.workspace = true6authors = ["Yaroslav Bolyukin <iam@lach.pw>"]7license = "MIT"8edition = "2021"910[features]11default = ["codegenerated-stdlib"]12# Speed-up initialization by generating code for parsed stdlib, instead13# of invoking parser for it14codegenerated-stdlib = ["jrsonnet-parser/structdump"]15# Enables legacy `std.thisFile` support, at the cost of worse caching16legacy-this-file = []17# Add order preservation flag to some functions18exp-preserve-order = ["jrsonnet-evaluator/exp-preserve-order"]19# Bigint type20exp-bigint = ["num-bigint", "jrsonnet-evaluator/exp-bigint"]2122[dependencies]23jrsonnet-evaluator.workspace = true24jrsonnet-macros.workspace = true25jrsonnet-parser.workspace = true26jrsonnet-gcmodule.workspace = true2728# Used for stdlib AST serialization29bincode = { version = "1.3", optional = true }30# Used both for stdlib AST serialization and std.parseJson/std.parseYaml31serde = "1.0"3233# std.md534md5 = "0.7.0"35# std.sha136sha1 = "0.10.5"37# std.sha256, std.sha51238sha2 = "0.10.6"39# std.sha340sha3 = "0.10.8"41# std.base6442base64 = "0.21.0"43# std.parseJson44serde_json = "1.0"45# std.parseYaml, custom library fork is used for C++/golang compatibility46serde_yaml_with_quirks = "0.8.24"4748num-bigint = { version = "0.4.3", optional = true }4950[build-dependencies]51jrsonnet-parser.workspace = true52structdump = { version = "0.2.0", features = ["derive"] }