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

difftreelog

fix std.join/std.flatmap accepts null in array

Yaroslav Bolyukin2022-04-22parent: #c7e1571.patch.diff
in: master

1 file changed

modifiedcrates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth
410 for c in str.chars() {410 for c in str.chars() {
411 match func.evaluate_simple(s.clone(), &[c.to_string()].as_slice())? {411 match func.evaluate_simple(s.clone(), &[c.to_string()].as_slice())? {
412 Val::Str(o) => out.push_str(&o),412 Val::Str(o) => out.push_str(&o),
413 Val::Null => continue,
413 _ => throw!(RuntimeError(414 _ => throw!(RuntimeError(
414 "in std.join all items should be strings".into()415 "in std.join all items should be strings".into()
415 )),416 )),
427 out.push(oe?);428 out.push(oe?);
428 }429 }
429 }430 }
431 Val::Null => continue,
430 _ => throw!(RuntimeError(432 _ => throw!(RuntimeError(
431 "in std.join all items should be arrays".into()433 "in std.join all items should be arrays".into()
432 )),434 )),
564 for item in items.iter(s.clone()) {566 for item in items.iter(s.clone()) {
565 out.push(item?);567 out.push(item?);
566 }568 }
567 } else {569 } else if matches!(item, Val::Null) {
570 continue;
571 } else {
568 throw!(RuntimeError(572 throw!(RuntimeError(
569 "in std.join all items should be arrays".into()573 "in std.join all items should be arrays".into()
570 ));574 ));
585 }589 }
586 first = false;590 first = false;
587 out += &item;591 out += &item;
588 } else {592 } else if matches!(item, Val::Null) {
593 continue;
594 } else {
589 throw!(RuntimeError(595 throw!(RuntimeError(
590 "in std.join all items should be strings".into()596 "in std.join all items should be strings".into()
591 ));597 ));