From 46589faaca9afae60c4b969f6dcd4315a3def9ed Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Mon, 30 Sep 2024 19:18:07 -0500 Subject: [PATCH] allow bools to be type checked with each other (#13968) # Description This PR allows bools to be type checked against each other. ![image](https://github.com/user-attachments/assets/64dc36f8-59bc-4e66-8380-6b693c77a2d3) I looked for test and maybe we don't have any for type checked math stuff. I didn't see any. # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-parser/src/type_check.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/nu-parser/src/type_check.rs b/crates/nu-parser/src/type_check.rs index 6a99aef247..bf268dac1a 100644 --- a/crates/nu-parser/src/type_check.rs +++ b/crates/nu-parser/src/type_check.rs @@ -480,6 +480,7 @@ pub fn math_result_type( (Type::Duration, Type::Duration) => (Type::Bool, None), (Type::Date, Type::Date) => (Type::Bool, None), (Type::Filesize, Type::Filesize) => (Type::Bool, None), + (Type::Bool, Type::Bool) => (Type::Bool, None), (Type::Custom(a), Type::Custom(b)) if a == b => (Type::Custom(a.clone()), None), (Type::Custom(a), _) => (Type::Custom(a.clone()), None), @@ -530,6 +531,7 @@ pub fn math_result_type( (Type::Duration, Type::Duration) => (Type::Bool, None), (Type::Date, Type::Date) => (Type::Bool, None), (Type::Filesize, Type::Filesize) => (Type::Bool, None), + (Type::Bool, Type::Bool) => (Type::Bool, None), (Type::Custom(a), Type::Custom(b)) if a == b => (Type::Custom(a.clone()), None), (Type::Custom(a), _) => (Type::Custom(a.clone()), None), @@ -580,6 +582,7 @@ pub fn math_result_type( (Type::Duration, Type::Duration) => (Type::Bool, None), (Type::Date, Type::Date) => (Type::Bool, None), (Type::Filesize, Type::Filesize) => (Type::Bool, None), + (Type::Bool, Type::Bool) => (Type::Bool, None), (Type::Custom(a), Type::Custom(b)) if a == b => (Type::Custom(a.clone()), None), (Type::Custom(a), _) => (Type::Custom(a.clone()), None), @@ -630,6 +633,7 @@ pub fn math_result_type( (Type::Duration, Type::Duration) => (Type::Bool, None), (Type::Date, Type::Date) => (Type::Bool, None), (Type::Filesize, Type::Filesize) => (Type::Bool, None), + (Type::Bool, Type::Bool) => (Type::Bool, None), (Type::Custom(a), Type::Custom(b)) if a == b => (Type::Custom(a.clone()), None), (Type::Custom(a), _) => (Type::Custom(a.clone()), None),