"fix the use of right hand expressions in operations"

This commit is contained in:
Jack Wright 2024-06-07 10:11:39 -07:00
parent d2121a155e
commit 50ef22308e

View File

@ -63,31 +63,18 @@ fn compute_with_value(
op: Span, op: Span,
right: &Value, right: &Value,
) -> Result<Value, ShellError> { ) -> Result<Value, ShellError> {
let rhs_span = right.span();
match right { match right {
Value::Custom { val: rhs, .. } => { Value::Custom { .. } => {
let rhs = rhs.as_any().downcast_ref::<NuExpression>().ok_or_else(|| { let rhs = NuExpression::try_from_value(plugin, right)?;
ShellError::TypeMismatch { with_operator(
err_message: "Right hand side not a dataframe expression".into(),
span: rhs_span,
}
})?;
match rhs.as_ref() {
polars::prelude::Expr::Literal(..) => with_operator(
(plugin, engine), (plugin, engine),
operator, operator,
left, left,
rhs, &rhs,
lhs_span, lhs_span,
right.span(), right.span(),
op, op,
), )
_ => Err(ShellError::TypeMismatch {
err_message: "Only literal expressions or number".into(),
span: right.span(),
}),
}
} }
_ => { _ => {
let rhs = NuExpression::try_from_value(plugin, right)?; let rhs = NuExpression::try_from_value(plugin, right)?;