mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 06:55:36 +02:00
Add ends-with operator and fix dataframe operator behavior (#5395)
* add ends-with operator * escape needles in dataframe operator regex patterns
This commit is contained in:
@ -4049,6 +4049,7 @@ pub fn parse_operator(
|
||||
b"not-in" => Operator::NotIn,
|
||||
b"mod" => Operator::Modulo,
|
||||
b"starts-with" => Operator::StartsWith,
|
||||
b"ends-with" => Operator::EndsWith,
|
||||
b"&&" | b"and" => Operator::And,
|
||||
b"||" | b"or" => Operator::Or,
|
||||
b"**" => Operator::Pow,
|
||||
|
@ -337,6 +337,24 @@ pub fn math_result_type(
|
||||
)
|
||||
}
|
||||
},
|
||||
Operator::EndsWith => match (&lhs.ty, &rhs.ty) {
|
||||
(Type::String, Type::String) => (Type::Bool, None),
|
||||
(Type::Any, _) => (Type::Bool, None),
|
||||
(_, Type::Any) => (Type::Bool, None),
|
||||
_ => {
|
||||
*op = Expression::garbage(op.span);
|
||||
(
|
||||
Type::Any,
|
||||
Some(ParseError::UnsupportedOperation(
|
||||
op.span,
|
||||
lhs.span,
|
||||
lhs.ty.clone(),
|
||||
rhs.span,
|
||||
rhs.ty.clone(),
|
||||
)),
|
||||
)
|
||||
}
|
||||
},
|
||||
Operator::In => match (&lhs.ty, &rhs.ty) {
|
||||
(t, Type::List(u)) if type_compatible(t, u) => (Type::Bool, None),
|
||||
(Type::Int | Type::Float, Type::Range) => (Type::Bool, None),
|
||||
|
Reference in New Issue
Block a user