Skip to content

Commit 55b23de

Browse files
committed
fixed onlyShowIf to always pass Bool
1 parent a0bc946 commit 55b23de

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

primitives/src/targeting/eval.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -802,11 +802,18 @@ fn eval(input: &Input, output: &mut Output, rule: &Rule) -> Result<Option<Value>
802802

803803
Some(Value::Bool(first_eval.ends_with(&second_eval)))
804804
}
805-
Function::OnlyShowIf(first_rule) => eval(
806-
input,
807-
output,
808-
&Rule::Function(Function::Set(String::from("show"), first_rule.clone())),
809-
)?,
805+
Function::OnlyShowIf(first_rule) => {
806+
let first_eval = first_rule
807+
.eval(input, output)?
808+
.ok_or(Error::TypeError)?
809+
.try_bool()?;
810+
let new_rule = Box::new(Rule::Value(Value::Bool(first_eval)));
811+
eval(
812+
input,
813+
output,
814+
&Rule::Function(Function::Set(String::from("show"), new_rule)),
815+
)?
816+
}
810817
Function::Do(first_rule) => eval(input, output, first_rule)?,
811818
Function::Set(key, rule) => {
812819
// Output variables can be set any number of times by different rules, except `show`

0 commit comments

Comments
 (0)