From f5e1b08e6aa46770edd961ebb20790c5a53170f7 Mon Sep 17 00:00:00 2001 From: pwygab <88221256+merelymyself@users.noreply.github.com> Date: Thu, 29 Sep 2022 19:17:21 +0800 Subject: [PATCH] ensure Operator::And errors out with incompatible types (#6638) --- crates/nu-engine/src/eval.rs | 2 +- crates/nu-protocol/src/value/mod.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/nu-engine/src/eval.rs b/crates/nu-engine/src/eval.rs index 539bcbe65..530dc2646 100644 --- a/crates/nu-engine/src/eval.rs +++ b/crates/nu-engine/src/eval.rs @@ -408,7 +408,7 @@ pub fn eval_expression( match op { Operator::And => { - if !lhs.is_true() { + if lhs.is_false() { Ok(Value::Bool { val: false, span: expr.span, diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index 145a88a0d..b32344889 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -1176,6 +1176,10 @@ impl Value { matches!(self, Value::Bool { val: true, .. }) } + pub fn is_false(&self) -> bool { + matches!(self, Value::Bool { val: false, .. }) + } + pub fn columns(&self) -> Vec { match self { Value::Record { cols, .. } => cols.clone(),