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

difftreelog

fix ObjValue is_empty should not account hidden fields

Yaroslav Bolyukin2024-06-18parent: #cc55b2d.patch.diff
in: master

2 files changed

modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -669,17 +669,18 @@
 	}
 
 	fn len(&self) -> usize {
+		// Maybe it will be better to not compute sort key here?
 		self.fields_visibility()
 			.into_iter()
 			.filter(|(_, (visible, _))| *visible)
 			.count()
 	}
 
+	/// Returns false only if there is any visible entry.
+	///
+	/// Note that object with hidden fields `{a:: 1}` will be reported as empty here.
 	fn is_empty(&self) -> bool {
-		if !self.this_entries.is_empty() {
-			return false;
-		}
-		self.sup.as_ref().map_or(true, ObjValue::is_empty)
+		self.len() != 0
 	}
 
 	/// Run callback for every field found in object
modifiedcrates/jrsonnet-stdlib/src/strings.rsdiffbeforeafterboth
28}28}
2929
30#[builtin]30#[builtin]
31pub fn builtin_escape_string_bash(str: String) -> String {31pub fn builtin_escape_string_bash(str_: String) -> String {
32 const QUOTE: char = '\'';32 const QUOTE: char = '\'';
33 let mut out = str.replace(QUOTE, "'\"'\"'");33 let mut out = str_.replace(QUOTE, "'\"'\"'");
34 out.insert(0, QUOTE);34 out.insert(0, QUOTE);
35 out.push(QUOTE);35 out.push(QUOTE);
36 out36 out