diff --git a/crates/nu-command/src/charting/histogram.rs b/crates/nu-command/src/charting/histogram.rs index 1353302ce0..d4559ddf8b 100644 --- a/crates/nu-command/src/charting/histogram.rs +++ b/crates/nu-command/src/charting/histogram.rs @@ -98,11 +98,17 @@ impl Command for Histogram { let frequency_name_arg = call.opt::>(engine_state, stack, 1)?; let frequency_column_name = match frequency_name_arg { Some(inner) => { - if ["value", "count", "quantile", "percentage"].contains(&inner.item.as_str()) { + let forbidden_column_names = ["value", "count", "quantile", "percentage"]; + if forbidden_column_names.contains(&inner.item.as_str()) { return Err(ShellError::TypeMismatch { - err_message: - "frequency-column-name can't be 'value', 'count' or 'percentage'" - .to_string(), + err_message: format!( + "frequency-column-name can't be {}", + forbidden_column_names + .iter() + .map(|val| format!("'{}'", val)) + .collect::>() + .join(", ") + ), span: inner.span, }); } diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index 3193c02a94..83ebddb718 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -2654,9 +2654,12 @@ impl Value { && (self.get_type() != Type::Any) && (rhs.get_type() != Type::Any) { - return Err(ShellError::TypeMismatch { - err_message: "compatible type".to_string(), - span: op, + return Err(ShellError::OperatorMismatch { + op_span: op, + lhs_ty: self.get_type(), + lhs_span: self.span()?, + rhs_ty: rhs.get_type(), + rhs_span: rhs.span()?, }); } @@ -2690,9 +2693,12 @@ impl Value { && (self.get_type() != Type::Any) && (rhs.get_type() != Type::Any) { - return Err(ShellError::TypeMismatch { - err_message: "compatible type".to_string(), - span: op, + return Err(ShellError::OperatorMismatch { + op_span: op, + lhs_ty: self.get_type(), + lhs_span: self.span()?, + rhs_ty: rhs.get_type(), + rhs_span: rhs.span()?, }); } @@ -2724,9 +2730,12 @@ impl Value { && (self.get_type() != Type::Any) && (rhs.get_type() != Type::Any) { - return Err(ShellError::TypeMismatch { - err_message: "compatible type".to_string(), - span: op, + return Err(ShellError::OperatorMismatch { + op_span: op, + lhs_ty: self.get_type(), + lhs_span: self.span()?, + rhs_ty: rhs.get_type(), + rhs_span: rhs.span()?, }); } @@ -2758,9 +2767,12 @@ impl Value { && (self.get_type() != Type::Any) && (rhs.get_type() != Type::Any) { - return Err(ShellError::TypeMismatch { - err_message: "compatible type".to_string(), - span: op, + return Err(ShellError::OperatorMismatch { + op_span: op, + lhs_ty: self.get_type(), + lhs_span: self.span()?, + rhs_ty: rhs.get_type(), + rhs_span: rhs.span()?, }); }