--- a/cmds/jrsonnet/src/main.rs +++ b/cmds/jrsonnet/src/main.rs @@ -136,7 +136,10 @@ let mut file = File::create(path)?; writeln!(file, "{}", state.manifest(val)?)?; } else { - println!("{}", state.manifest(val)?); + let output = state.manifest(val)?; + if !output.is_empty() { + println!("{}", output); + } } Ok(()) --- 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('}'); --- 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));