git.delta.rocks / jrsonnet / refs/commits / 00b4f053911b

difftreelog

Merge branch 'master' of github.com:CertainLach/jrsonnet into type-safety

Yaroslav Bolyukin2021-01-24parents: #3fc6c25 #847c11f.patch.diff
in: master

3 files changed

modifiedcmds/jrsonnet/src/main.rsdiffbeforeafterboth
136 let mut file = File::create(path)?;136 let mut file = File::create(path)?;
137 writeln!(file, "{}", state.manifest(val)?)?;137 writeln!(file, "{}", state.manifest(val)?)?;
138 } else {138 } else {
139 println!("{}", state.manifest(val)?);139 let output = state.manifest(val)?;
140 if !output.is_empty() {
141 println!("{}", output);
142 }
140 }143 }
141144
142 Ok(())145 Ok(())
modifiedcrates/jrsonnet-evaluator/src/builtin/manifest.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/manifest.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/manifest.rs
@@ -74,7 +74,7 @@
 			} else if mtype == ManifestType::Std {
 				buf.push_str("\n\n");
 				buf.push_str(cur_padding);
-			} else if mtype == ManifestType::ToString {
+			} else if mtype == ManifestType::ToString || mtype == ManifestType::Manifest {
 				buf.push(' ');
 			}
 			buf.push(']');
@@ -112,7 +112,7 @@
 			} else if mtype == ManifestType::Std {
 				buf.push_str("\n\n");
 				buf.push_str(cur_padding);
-			} else if mtype == ManifestType::ToString {
+			} else if mtype == ManifestType::ToString || mtype == ManifestType::Manifest {
 				buf.push(' ');
 			}
 			buf.push('}');
modifiedcrates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/mod.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/mod.rs
@@ -378,6 +378,9 @@
 		0, from: ty!(number) => Val::Num;
 		1, to: ty!(number) => Val::Num;
 	], {
+		if to < from {
+			return Ok(Val::Arr(Rc::new(Vec::new())))
+		}
 		let mut out = Vec::with_capacity((1+to as usize-from as usize).max(0));
 		for i in from as usize..=to as usize {
 			out.push(Val::Num(i as f64));