You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following (invalid, as b is not defined) snippet
[x.value for x in std.objectKeysValues({ a: b })]
seems to trigger a panic during evaluation:
thread 'main' panicked at jrsonnet/crates/jrsonnet-evaluator/src/arr/spec.rs:658:14:
convertible: LocError((VariableIsNotDefined("b", []), StackTrace([StackTraceElement { location: Some(Source((SourcePath(SourceVirtual("input.jsonnet")), "[x.value for x in std.objectKeysValues({ a: b })]")):44-45), desc: "variable <b> access" }])))
// Nothing can fail in the key part, yet value is still
// lazy-evaluated
Some(Thunk::evaluated(
KeyValue::into_untyped(KeyValue{
key: key.clone(),
value:self.obj.get_lazy_or_bail(key.clone()),
})
.expect("convertible"),
The following patch seems to work to propagate the error without a panic:
modified crates/jrsonnet-evaluator/src/arr/spec.rs
@@ -648,15 +648,14 @@ impl ArrayLike for PickObjectKeyValues {
fn get_lazy(&self, index: usize) -> Option<Thunk<Val>> {
let key = self.keys.get(index)?;
- // Nothing can fail in the key part, yet value is still- // lazy-evaluated- Some(Thunk::evaluated(+ Some(
KeyValue::into_untyped(KeyValue {
key: key.clone(),
value: self.obj.get_lazy_or_bail(key.clone()),
})
- .expect("convertible"),- ))+ .map(Thunk::evaluated)+ .unwrap_or_else(Thunk::errored),+ )
}
LocError((VariableIsNotDefined("b", []), StackTrace([StackTraceElement { location: Some(Source((SourcePath(SourceVirtual("input.jsonnet")), "[x.value for x in std.objectKeysValues({ a: b })]")):44-45), desc: "variable <b> access" }, StackTraceElement { location: Some(Source((SourcePath(SourceVirtual("input.jsonnet")), "[x.value for x in std.objectKeysValues({ a: b })]")):1-2), desc: "variable <x> access" }])))
The text was updated successfully, but these errors were encountered:
The following (invalid, as
b
is not defined) snippetseems to trigger a panic during evaluation:
The relevant code is here:
jrsonnet/crates/jrsonnet-evaluator/src/arr/spec.rs
Lines 656 to 665 in 74ea504
The following patch seems to work to propagate the error without a panic:
The text was updated successfully, but these errors were encountered: